mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Add options to choose audio language for the video (default is English)
This commit is contained in:
parent
605f1a8d67
commit
f3e0369710
6 changed files with 85 additions and 3 deletions
|
@ -95,6 +95,7 @@ Options:
|
||||||
See nfo_example.txt for more details
|
See nfo_example.txt for more details
|
||||||
--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)
|
||||||
-h --help Show this help.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
|
|
||||||
|
@ -106,6 +107,12 @@ Categories:
|
||||||
comedy, entertainment, news,
|
comedy, entertainment, news,
|
||||||
how to, education, activism, science & technology,
|
how to, education, activism, science & technology,
|
||||||
science, technology, animals
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
@ -120,7 +127,7 @@ Categories:
|
||||||
- [x] privacy (between public, unlisted or private)
|
- [x] privacy (between public, unlisted or private)
|
||||||
- [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
|
- [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
|
||||||
- [x] nsfw (Peertube only as Youtube API does not support it)
|
- [x] nsfw (Peertube only as Youtube API does not support it)
|
||||||
- [ ] set default language
|
- [x] set default language
|
||||||
- ~~thumbnail/preview~~ Canceled, waiting for Youtube's API support
|
- ~~thumbnail/preview~~ Canceled, waiting for Youtube's API support
|
||||||
- [x] Use a config file (NFO) file to retrieve videos arguments
|
- [x] Use a config file (NFO) file to retrieve videos arguments
|
||||||
- [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
|
- [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
|
||||||
|
|
|
@ -83,6 +83,12 @@ def upload_video(oauth, secret, options):
|
||||||
# if no category, set default to 2 (Films)
|
# if no category, set default to 2 (Films)
|
||||||
fields.append(("category", "2"))
|
fields.append(("category", "2"))
|
||||||
|
|
||||||
|
if options.get('--language'):
|
||||||
|
fields.append(("language", str(utils.getLanguage(options.get('--language'), "peertube"))))
|
||||||
|
else:
|
||||||
|
# if no language, set default to 1 (English)
|
||||||
|
fields.append(("language", "1"))
|
||||||
|
|
||||||
if options.get('--privacy'):
|
if options.get('--privacy'):
|
||||||
fields.append(("privacy", str(PEERTUBE_PRIVACY[options.get('--privacy').lower()])))
|
fields.append(("privacy", str(PEERTUBE_PRIVACY[options.get('--privacy').lower()])))
|
||||||
else:
|
else:
|
||||||
|
|
38
lib/utils.py
38
lib/utils.py
|
@ -45,7 +45,38 @@ PEERTUBE_CATEGORY = {
|
||||||
"animals": 16
|
"animals": 16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### LANGUAGES ###
|
||||||
|
YOUTUBE_LANGUAGE = {
|
||||||
|
"arabic": 'ar',
|
||||||
|
"english": 'en',
|
||||||
|
"french": 'fr',
|
||||||
|
"german": 'de',
|
||||||
|
"hindi": 'hi',
|
||||||
|
"italian": 'it',
|
||||||
|
"japanese": 'ja',
|
||||||
|
"korean": 'ko',
|
||||||
|
"mandarin": 'zh-CN',
|
||||||
|
"portuguese": 'pt-PT',
|
||||||
|
"punjabi": 'pa',
|
||||||
|
"russian": 'ru',
|
||||||
|
"spanish": 'es'
|
||||||
|
}
|
||||||
|
|
||||||
|
PEERTUBE_LANGUAGE = {
|
||||||
|
"arabic": 5,
|
||||||
|
"english": 1,
|
||||||
|
"french": 13,
|
||||||
|
"german": 11,
|
||||||
|
"hindi": 4,
|
||||||
|
"italian": 14,
|
||||||
|
"japanese": 9,
|
||||||
|
"korean": 12,
|
||||||
|
"mandarin": 3,
|
||||||
|
"portuguese": 6,
|
||||||
|
"punjabi": 10,
|
||||||
|
"russian": 8,
|
||||||
|
"spanish": 2
|
||||||
|
}
|
||||||
######################
|
######################
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +87,13 @@ def getCategory(category, platform):
|
||||||
return PEERTUBE_CATEGORY[category.lower()]
|
return PEERTUBE_CATEGORY[category.lower()]
|
||||||
|
|
||||||
|
|
||||||
|
def getLanguage(language, platform):
|
||||||
|
if platform == "youtube":
|
||||||
|
return YOUTUBE_LANGUAGE[language.lower()]
|
||||||
|
else:
|
||||||
|
return PEERTUBE_LANGUAGE[language.lower()]
|
||||||
|
|
||||||
|
|
||||||
# return the nfo as a RawConfigParser object
|
# return the nfo as a RawConfigParser object
|
||||||
def loadNFO(options):
|
def loadNFO(options):
|
||||||
video_directory = dirname(options.get('--file')) + "/"
|
video_directory = dirname(options.get('--file')) + "/"
|
||||||
|
|
|
@ -81,6 +81,10 @@ def initialize_upload(youtube, options):
|
||||||
if options.get('--category'):
|
if options.get('--category'):
|
||||||
category = utils.getCategory(options.get('--category'), 'youtube')
|
category = utils.getCategory(options.get('--category'), 'youtube')
|
||||||
|
|
||||||
|
language = None
|
||||||
|
if options.get('--language'):
|
||||||
|
language = utils.getLanguage(options.get('--language'), "youtube")
|
||||||
|
|
||||||
license = None
|
license = None
|
||||||
if options.get('--cca'):
|
if options.get('--cca'):
|
||||||
license = "creativeCommon"
|
license = "creativeCommon"
|
||||||
|
@ -92,6 +96,7 @@ def initialize_upload(youtube, options):
|
||||||
"tags": tags,
|
"tags": tags,
|
||||||
# if no category, set default to 1 (Films)
|
# if no category, set default to 1 (Films)
|
||||||
"categoryId": str(category or 1),
|
"categoryId": str(category or 1),
|
||||||
|
"defaultAudioLanguage": str(language or 'en')
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"privacyStatus": str(options.get('--privacy') or "private"),
|
"privacyStatus": str(options.get('--privacy') or "private"),
|
||||||
|
|
|
@ -14,4 +14,5 @@ cca = True
|
||||||
privacy = private
|
privacy = private
|
||||||
disable-comments = True
|
disable-comments = True
|
||||||
nsfw = True
|
nsfw = True
|
||||||
platform = youtub
|
platform = youtube, peertube
|
||||||
|
language = French
|
|
@ -23,6 +23,7 @@ Options:
|
||||||
See nfo_example.txt for more details
|
See nfo_example.txt for more details
|
||||||
--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)
|
||||||
-h --help Show this help.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
|
|
||||||
|
@ -34,6 +35,13 @@ Categories:
|
||||||
comedy, entertainment, news,
|
comedy, entertainment, news,
|
||||||
how to, education, activism, science & technology,
|
how to, education, activism, science & technology,
|
||||||
science, technology, animals
|
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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from os.path import dirname, realpath
|
from os.path import dirname, realpath
|
||||||
import sys
|
import sys
|
||||||
|
@ -64,6 +72,7 @@ except ImportError:
|
||||||
'see https://github.com/ahupp/python-magic\n')
|
'see https://github.com/ahupp/python-magic\n')
|
||||||
|
|
||||||
VERSION = "prismedia v0.3"
|
VERSION = "prismedia v0.3"
|
||||||
|
|
||||||
VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
|
VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
|
||||||
VALID_CATEGORIES = (
|
VALID_CATEGORIES = (
|
||||||
"music", "films", "vehicles",
|
"music", "films", "vehicles",
|
||||||
|
@ -73,6 +82,10 @@ VALID_CATEGORIES = (
|
||||||
"science", "technology", "animals"
|
"science", "technology", "animals"
|
||||||
)
|
)
|
||||||
VALID_PLATFORM = ('youtube', 'peertube')
|
VALID_PLATFORM = ('youtube', 'peertube')
|
||||||
|
VALID_LANGUAGES = ('arabic', 'english', 'french',
|
||||||
|
'german', 'hindi', 'italian',
|
||||||
|
'japanese', 'korean', 'mandarin',
|
||||||
|
'portuguese', 'punjabi', 'russian', 'spanish')
|
||||||
|
|
||||||
|
|
||||||
def validateVideo(path):
|
def validateVideo(path):
|
||||||
|
@ -99,12 +112,19 @@ def validatePrivacy(privacy):
|
||||||
|
|
||||||
def validatePlatform(platform):
|
def validatePlatform(platform):
|
||||||
for plfrm in platform.split(','):
|
for plfrm in platform.split(','):
|
||||||
if plfrm not in VALID_PLATFORM:
|
if plfrm.lower().replace(" ", "") not in VALID_PLATFORM:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def validateLanguage(language):
|
||||||
|
if language.lower() in VALID_LANGUAGES:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
options = docopt(__doc__, version=VERSION)
|
options = docopt(__doc__, version=VERSION)
|
||||||
|
@ -131,6 +151,11 @@ if __name__ == '__main__':
|
||||||
validateCategory,
|
validateCategory,
|
||||||
error="Category not recognized, please see --help")
|
error="Category not recognized, please see --help")
|
||||||
),
|
),
|
||||||
|
Optional('--language'): Or(None, And(
|
||||||
|
str,
|
||||||
|
validateLanguage,
|
||||||
|
error="Language not recognized, please see --help")
|
||||||
|
),
|
||||||
Optional('--privacy'): Or(None, And(
|
Optional('--privacy'): Or(None, And(
|
||||||
str,
|
str,
|
||||||
validatePrivacy,
|
validatePrivacy,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue