From 8dc3a86aabd62f164be9bc24650b594f25dbe44e Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Tue, 1 Dec 2020 09:24:36 +0100 Subject: [PATCH] Stripe the README from the full --help output to focus on some main features --- README.md | 99 ++++-------------------------------------- prismedia/yt_upload.py | 22 +++++----- 2 files changed, 18 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index 41e7585..4139c9f 100644 --- a/README.md +++ b/README.md @@ -92,24 +92,27 @@ If you plan a larger usage, please consider creating your own youtube_secret fil Support only mp4 for cross compatibility between Youtube and Peertube. **Note that all options may be specified in a NFO file!** (see [Enhanced NFO](#enhanced-use-of-nfo)) -Upload a video: +Here are some demonstration of main usage you would like! +Upload a video: ``` prismedia --file="yourvideo.mp4" ``` Specify description and tags: - ``` prismedia --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo" ``` Provide a thumbnail: - ``` prismedia --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg" ``` +Publish on Peertube only, while using a channel and a playlist, creating them if they does not exist.: +``` +prismedia --file="yourvideo.mp4" --platform=peertube --channel="Cooking recipes" --playlist="Cake recipes" --channelCreate --playlistCreate +``` Use a NFO file to specify your video options: (See [Enhanced NFO](#enhanced-use-of-nfo) for more precise example) @@ -118,95 +121,9 @@ prismedia --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt ``` -Use --help to get all available options: - +Take a look at all available options with `--help`! ``` -Options: - -f, --file=STRING Path to the video file to upload in mp4. This is the only mandatory option. - --name=NAME Name of the video to upload. (default to video filename) - -d, --description=STRING Description of the video. (default: default description) - -t, --tags=STRING Tags for the video. comma separated. - WARN: tags with punctuation (!, ', ", ?, ...) - are not supported by Mastodon to be published from Peertube - -c, --category=STRING Category for the videos, see below. (default: Films) - --cca License should be CreativeCommon Attribution (affects Youtube upload only) - -p, --privacy=STRING Choose between public, unlisted or private. (default: private) - --disable-comments Disable comments (Peertube only as YT API does not support) (default: comments are enabled) - --nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) (default: video is safe) - --nfo=STRING Configure a specific nfo file to set options for the video. - 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) - See nfo_example.txt for more details - --platform=STRING List of platform(s) to upload to, comma separated. - 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) - --publishAt=DATE Publish the video at the given DATE using local server timezone. - DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00 - DATE should be in the future - --peertubeAt=DATE - --youtubeAt=DATE Override publishAt for the corresponding platform. Allow to create preview on specific platform - --originalDate=DATE Configure the video as initially recorded at DATE - DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00 - DATE should be in the past - Default use the last modification date of the file. - --no-originalDate Do not set the initial record field when uploading - --thumbnail=STRING Path to a file to use as a thumbnail for the video. - Supported types are jpg and jpeg. - By default, prismedia search for an image based on video name followed by .jpg or .jpeg - --channel=STRING Set the channel to use for the video (Peertube only) - If the channel is not found, spawn an error except if --channelCreate is set. - --channelCreate Create the channel if not exists. (Peertube only, default do not create) - Only relevant if --channel is set. - --playlist=STRING Set the playlist to use for the video. - If the playlist is not found, spawn an error except if --playlistCreate is set. - --playlistCreate Create the playlist if not exists. (default do not create) - Only relevant if --playlist is set. - -h --help Show this help. - --version Show version. - -Logging options - -q --quiet Suppress any log except Critical (alias for --log=critical). - --log=STRING Log level, between debug, info, warning, error, critical. Ignored if --quiet is set (default to info) - -u --url-only Display generated URL after upload directly on stdout, implies --quiet - --batch Display generated URL after upload with platform information for easier parsing. Implies --quiet - Be careful --batch and --url-only are mutually exclusives. - --debug (Deprecated) Alias for --log=debug. Ignored if --log is set - -Strict options: - Strict options allow you to force some option to be present when uploading a video. It's useful to be sure you do not - forget something when uploading a video, for example if you use multiples NFO. You may force the presence of description, - tags, thumbnail, ... - All strict option are optionals and are provided only to avoid errors when uploading :-) - All strict options can be specified in NFO directly, the only strict option mandatory on cli is --withNFO - All strict options are off by default - - --withNFO Prevent the upload without a NFO, either specified via cli or found in the directory - --withThumbnail Prevent the upload without a thumbnail - --withName Prevent the upload if no name are found - --withDescription Prevent the upload without description - --withTags Prevent the upload without tags - --withPlaylist Prevent the upload if no playlist - --withPublishAt Prevent the upload if no schedule - --withPlatform Prevent the upload if at least one platform is not specified - --withCategory Prevent the upload if no category - --withLanguage Prevent upload if no language - --withChannel Prevent upload if no channel - -Categories: - Category is the type of video you upload. Default is films. - Here are available categories from Peertube and Youtube: - music, films, vehicles, - sports, travels, gaming, people, - comedy, entertainment, news, - how to, education, activism, science & technology, - science, technology, animals - -Languages: - Language of the video (audio track), choose one. Default is English - Here are available languages from Peertube and Youtube: - Arabic, English, French, German, Hindi, Italian, - Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish - +prismedia --help ``` ## Enhanced use of NFO diff --git a/prismedia/yt_upload.py b/prismedia/yt_upload.py index c08619a..afccf1a 100644 --- a/prismedia/yt_upload.py +++ b/prismedia/yt_upload.py @@ -89,6 +89,14 @@ def check_authenticated_scopes(): os.remove(CREDENTIALS_PATH) +def convert_youtube_date(date): + # Youtube needs microsecond and the local timezone from ISO 8601 + date = date + ".000001" + date = datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%f') + tz = get_localzone() + tz = pytz.timezone(str(tz)) + return tz.localize(date).isoformat() + def initialize_upload(youtube, options): path = options.get('--file') tags = None @@ -133,22 +141,12 @@ def initialize_upload(youtube, options): # Check if publishAt variable exists in local variables if 'publishAt' in locals(): - # Youtube needs microsecond and the local timezone from ISO 8601 - publishAt = publishAt + ".000001" - publishAt = datetime.datetime.strptime(publishAt, '%Y-%m-%dT%H:%M:%S.%f') - tz = get_localzone() - tz = pytz.timezone(str(tz)) - publishAt = tz.localize(publishAt).isoformat() + publishAt = convert_youtube_date(publishAt) body['status']['publishAt'] = str(publishAt) # Set originalDate except if the user force no originalDate if not options.get('--no-originalDate'): - # Youtube needs microsecond and the local timezone from ISO 8601 - originalDate = options.get('--originalDate') + ".000001" - originalDate = datetime.datetime.strptime(originalDate, '%Y-%m-%dT%H:%M:%S.%f') - tz = get_localzone() - tz = pytz.timezone(str(tz)) - originalDate = tz.localize(originalDate).isoformat() + originalDate = convert_youtube_date(options.get('--originalDate')) body['recordingDetails']['recordingDate'] = str(originalDate) if options.get('--playlist'):