mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Add credsdir option from ysalmon-credsdir
This commit is contained in:
commit
325cee4a69
4 changed files with 21 additions and 7 deletions
10
README.md
10
README.md
|
@ -83,10 +83,12 @@ If you plan a larger usage, please consider creating your own youtube_secret fil
|
||||||
|
|
||||||
- Go to the [Google console](https://console.developers.google.com/).
|
- Go to the [Google console](https://console.developers.google.com/).
|
||||||
- Create project.
|
- Create project.
|
||||||
- Side menu: APIs & auth -> APIs
|
- Side menu: APIs & Services -> APIs
|
||||||
- Top menu: Enabled API(s): Enable all Youtube APIs.
|
- Top menu: Enabled API(s): Enable Youtube Data v3 APIs.
|
||||||
- Side menu: APIs & auth -> Credentials.
|
- Side menu: OAuth consent screen
|
||||||
- Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK
|
- Create an app -> User type External -> Add scope from Youtube Data API v3: `.../auth/youtube.force-ssl` and `.../auth/youtube.upload` -> No test user -> save & create
|
||||||
|
- Side menu: APIs & Services -> Credentials.
|
||||||
|
- Create a Client ID: Create credentials -> OAuth Client ID -> Other -> Name: prismedia1 -> Create -> OK
|
||||||
- Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system.
|
- Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system.
|
||||||
- Save this JSON as your youtube_secret.json file.
|
- Save this JSON as your youtube_secret.json file.
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,10 @@ def create_callback(encoder, progress_type):
|
||||||
def run(options):
|
def run(options):
|
||||||
secret = RawConfigParser()
|
secret = RawConfigParser()
|
||||||
try:
|
try:
|
||||||
secret.read(PEERTUBE_SECRETS_FILE)
|
if options.get('--credentialsdir') :
|
||||||
|
secret.read(os.path.join(options.get('--credentialsdir'), PEERTUBE_SECRETS_FILE))
|
||||||
|
else :
|
||||||
|
secret.read(PEERTUBE_SECRETS_FILE)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.critical("Peertube: Error loading " + str(PEERTUBE_SECRETS_FILE) + ": " + str(e))
|
logger.critical("Peertube: Error loading " + str(PEERTUBE_SECRETS_FILE) + ": " + str(e))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -27,6 +27,7 @@ Options:
|
||||||
By default Prismedia search a .txt based on the video name and will
|
By default Prismedia search a .txt based on the video name and will
|
||||||
decode the file as UTF-8 (so make sure your nfo file is UTF-8 encoded)
|
decode the file as UTF-8 (so make sure your nfo file is UTF-8 encoded)
|
||||||
See nfo_example.txt for more details
|
See nfo_example.txt for more details
|
||||||
|
--credentialsdir=STRING Set directory where to search for secret file.
|
||||||
--platform=STRING List of platform(s) to upload to, comma separated.
|
--platform=STRING List of platform(s) to upload to, comma separated.
|
||||||
Supported platforms are youtube and peertube (default is both)
|
Supported platforms are youtube and peertube (default is both)
|
||||||
--language=STRING Specify the default language for video. See below for supported language. (default is English)
|
--language=STRING Specify the default language for video. See below for supported language. (default is English)
|
||||||
|
@ -279,6 +280,7 @@ def main():
|
||||||
Optional('--withCategory', default=False): bool,
|
Optional('--withCategory', default=False): bool,
|
||||||
Optional('--withLanguage', default=False): bool,
|
Optional('--withLanguage', default=False): bool,
|
||||||
Optional('--withChannel', default=False): bool,
|
Optional('--withChannel', default=False): bool,
|
||||||
|
Optional('--credentialsdir'): Or(None, And(str, os.path.exists, error='credentialsdir does not exist')),
|
||||||
# This allow to return all other options for further use: https://github.com/keleshev/schema#extra-keys
|
# This allow to return all other options for further use: https://github.com/keleshev/schema#extra-keys
|
||||||
object: object
|
object: object
|
||||||
})
|
})
|
||||||
|
|
|
@ -48,8 +48,8 @@ RETRIABLE_EXCEPTIONS = (
|
||||||
RETRIABLE_STATUS_CODES = [500, 502, 503, 504]
|
RETRIABLE_STATUS_CODES = [500, 502, 503, 504]
|
||||||
|
|
||||||
|
|
||||||
CLIENT_SECRETS_FILE = 'youtube_secret.json'
|
CLIENT_SECRETS_FILE_BASE = 'youtube_secret.json'
|
||||||
CREDENTIALS_PATH = ".youtube_credentials.json"
|
CREDENTIALS_PATH_BASE = ".youtube_credentials.json"
|
||||||
SCOPES = ['https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.force-ssl']
|
SCOPES = ['https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.force-ssl']
|
||||||
API_SERVICE_NAME = 'youtube'
|
API_SERVICE_NAME = 'youtube'
|
||||||
API_VERSION = 'v3'
|
API_VERSION = 'v3'
|
||||||
|
@ -358,6 +358,13 @@ def hearthbeat():
|
||||||
|
|
||||||
|
|
||||||
def run(options):
|
def run(options):
|
||||||
|
global CLIENT_SECRETS_FILE, CREDENTIALS_PATH
|
||||||
|
if options.get('--credentialsdir') :
|
||||||
|
CLIENT_SECRETS_FILE = os.path.join(options.get('--credentialsdir'), CLIENT_SECRETS_FILE_BASE)
|
||||||
|
CREDENTIALS_PATH = os.path.join(options.get('--credentialsdir'), CREDENTIALS_PATH_BASE)
|
||||||
|
else :
|
||||||
|
CLIENT_SECRETS_FILE = CLIENT_SECRETS_FILE_BASE
|
||||||
|
CREDENTIALS_PATH = CREDENTIALS_PATH_BASE
|
||||||
youtube = get_authenticated_service()
|
youtube = get_authenticated_service()
|
||||||
try:
|
try:
|
||||||
initialize_upload(youtube, options)
|
initialize_upload(youtube, options)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue