diff --git a/README.md b/README.md index c643fad..5761e06 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prismedia -Scripting your way to upload videos to peertube and youtube. +Scripting your way to upload videos to peertube and youtube. Works only with Python 2 so far. ## Dependencies @@ -38,18 +38,20 @@ You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not re ### Youtube -Youtube uses combination of oauth and API access to identify. +Youtube uses OAuth 2.0 to restrict its API access to identified users. Registering a client is documented [here](https://developers.google.com/youtube/v3/guides/uploading_a_video). -**Credentials** -The first time you connect, prismedia will open your browser to as you to authenticate to -Youtube and allow the app to use your Youtube channel. -**It is here you choose which channel you will upload to**. -Once authenticated, the token is stored inside the file ``.youtube_credentials.json``. -Prismedia will try to use this file at each launch, and re-ask for authentication if it does not exist. +**Credentials:** the first time you connect, prismedia will open your browser +to as you to authenticate to Youtube and allow the app to use your Youtube +channel. -**Oauth**: -The default youtube_secret.json should allow you to upload some videos. -If you plan an larger usage, please consider creating your own youtube_secret file: +**It is here you choose which channel you will upload to:** once authenticated, +the token is stored inside the file `.youtube_credentials.json`. Prismedia will +try to use this file at each launch, and re-ask for authentication if it does +not exist. + +**OAuth 2.0**: the default `youtube_secret.json` should allow you to upload +some videos. If you plan a more frequent usage, please consider creating your +own `youtube_secret` file: - Go to the [Google console](https://console.developers.google.com/). - Create project. @@ -69,26 +71,26 @@ Supports only mp4 for cross compatibility between Youtube and Peertube. Simply upload a video: ``` -./prismedia_upload.py --file="yourvideo.mp4" +python -m prismedia.upload --file="yourvideo.mp4" ``` Specify description and tags: ``` -./prismedia_upload.py --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo" +python -m prismedia.upload --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo" ``` Provide a thumbnail: ``` -./prismedia_upload.py --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg" +python -m prismedia.upload --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg" ``` Use a NFO file to specify your video options: ``` -./prismedia_upload.py --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt +python -m prismedia.upload --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt ``` Use --help to get all available options: diff --git a/prismedia/__init__.py b/prismedia/__init__.py new file mode 100644 index 0000000..37de3b8 --- /dev/null +++ b/prismedia/__init__.py @@ -0,0 +1 @@ +from . import upload diff --git a/lib/pt_upload.py b/prismedia/pt_upload.py similarity index 100% rename from lib/pt_upload.py rename to prismedia/pt_upload.py diff --git a/prismedia_upload.py b/prismedia/upload.py similarity index 97% rename from prismedia_upload.py rename to prismedia/upload.py index 00f64ae..8d424b4 100755 --- a/prismedia_upload.py +++ b/prismedia/upload.py @@ -59,8 +59,6 @@ Languages: Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish """ -from os.path import dirname, realpath -import sys import datetime import locale import logging @@ -68,12 +66,9 @@ logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) from docopt import docopt -# Allows a relative import from the parent folder -sys.path.insert(0, dirname(realpath(__file__)) + "/lib") - -import yt_upload -import pt_upload -import utils +from . import yt_upload +from . import pt_upload +from . import utils try: # noinspection PyUnresolvedReferences @@ -158,8 +153,7 @@ def validateThumbnail(thumbnail): else: return False -if __name__ == '__main__': - +def main(): options = docopt(__doc__, version=VERSION) schema = Schema({ @@ -228,3 +222,7 @@ if __name__ == '__main__': yt_upload.run(options) if options.get('--platform') is None or "peertube" in options.get('--platform'): pt_upload.run(options) + +if __name__ == '__main__': + main() + diff --git a/lib/utils.py b/prismedia/utils.py similarity index 100% rename from lib/utils.py rename to prismedia/utils.py diff --git a/lib/yt_upload.py b/prismedia/yt_upload.py similarity index 100% rename from lib/yt_upload.py rename to prismedia/yt_upload.py diff --git a/pyproject.toml b/pyproject.toml index 90abcb3..7f162b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,14 +3,18 @@ name = "prismedia" version = "0.6.2" description = "scripting your way to upload videos on peertube and youtube" authors = [ - "LecygneNoir " + "LecygneNoir ", "Rigel Kent " ] + license = "AGPL-3.0-only" + readme = 'README.md' repository = "https://git.lecygnenoir.info/LecygneNoir/prismedia" homepage = "https://git.lecygnenoir.info/LecygneNoir/prismedia" +keywords = ['peertube', 'youtube'] + [tool.poetry.dependencies] python = "^2.7" google-auth-oauthlib = "^0.2.0" @@ -28,3 +32,6 @@ google-api-python-client = "^1.7" [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" + +[tool.poetry.scripts] +prismedia = 'prismedia.upload:main'