Browse Source

Add option to choose which platform to upload to (default is Youtube and Peertube)

develop
LecygneNoir 6 years ago
parent
commit
5c5c70b246
2 changed files with 21 additions and 3 deletions
  1. +3
    -1
      README.md
  2. +18
    -2
      prismedia_upload.py

+ 3
- 1
README.md View File

@ -93,6 +93,8 @@ Options:
--nfo=STRING Configure a specific nfo file to set options for the video.
By default Prismedia search a .txt based on video name
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)
-h --help Show this help.
--version Show version.
@ -121,7 +123,7 @@ Categories:
- [ ] set default language
- ~~thumbnail/preview~~ Canceled, waiting for Youtube's API support
- [x] Use a config file (NFO) file to retrieve videos arguments
- [ ] 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)
- [ ] Record and forget: put the video in a directory, and the script uploads it for you
- [ ] Usable on Desktop (Linux and/or Windows and/or MacOS)
- [ ] Graphical User Interface

+ 18
- 2
prismedia_upload.py View File

@ -21,6 +21,8 @@ Options:
--nfo=STRING Configure a specific nfo file to set options for the video.
By default Prismedia search a .txt based on video name
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)
-h --help Show this help.
--version Show version.
@ -47,12 +49,14 @@ import pt_upload
import utils
try:
# noinspection PyUnresolvedReferences
from schema import Schema, And, Or, Optional, SchemaError
except ImportError:
exit('This program requires that the `schema` data-validation library'
' is installed: \n'
'see https://github.com/halst/schema\n')
try:
# noinspection PyUnresolvedReferences
import magic
except ImportError:
exit('This program requires that the `python-magic` library'
@ -68,6 +72,7 @@ VALID_CATEGORIES = (
"how to", "education", "activism", "science & technology",
"science", "technology", "animals"
)
VALID_PLATFORM = ('youtube', 'peertube')
def validateVideo(path):
@ -92,6 +97,14 @@ def validatePrivacy(privacy):
return False
def validatePlatform(platform):
for plfrm in platform.split(','):
if plfrm not in VALID_PLATFORM:
return False
return True
if __name__ == '__main__':
options = docopt(__doc__, version=VERSION)
@ -124,6 +137,7 @@ if __name__ == '__main__':
error="Please use recognized privacy between public, unlisted or private")
),
Optional('--nfo'): Or(None, str),
Optional('--platform'): Or(None, And(str, validatePlatform, error="Sorry, upload platform not supported")),
Optional('--cca'): bool,
Optional('--disable-comments'): bool,
Optional('--nsfw'): bool,
@ -138,5 +152,7 @@ if __name__ == '__main__':
options = utils.parseNFO(options)
yt_upload.run(options)
pt_upload.run(options)
if options.get('--platform') is None or "youtube" in options.get('--platform'):
yt_upload.run(options)
if options.get('--platform') is None or "peertube" in options.get('--platform'):
pt_upload.run(options)

Loading…
Cancel
Save