Browse Source

Merge branch 'feature/improve_genconfig' into develop

plugins
LecygneNoir 3 years ago
parent
commit
ba2a1ebb79
6 changed files with 46 additions and 20 deletions
  1. +17
    -11
      README.md
  2. +8
    -1
      prismedia/__init__.py
  3. +11
    -2
      prismedia/genconfig.py
  4. +0
    -6
      prismedia/upload.py
  5. +9
    -0
      prismedia/utils.py
  6. +1
    -0
      pyproject.toml

+ 17
- 11
README.md View File

@ -41,7 +41,7 @@ git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git prismedia
```
You may use pip to install requirements: `pip install -r requirements.txt` if you want to use the script directly.
(*note:* requirements are generated via `poetry export -f requirements.txt`)
(**note:** requirements are generated via `poetry export -f requirements.txt`)
Otherwise, you can use [poetry](https://python-poetry.org), which create a virtualenv for the project directly
(Or use the existing virtualenv if one is activated)
@ -50,18 +50,24 @@ Otherwise, you can use [poetry](https://python-poetry.org), which create a virtu
poetry install
```
## Configuration
Generate sample files with `python -m prismedia.genconfig`.
Then rename and edit `peertube_secret` and `youtube_secret.json` with your credentials. (see below)
Generate configuration files by running `prismedia-init`.
Then, edit them to fill your credential as explained below.
### Peertube
Set your credentials, peertube server URL.
You can get client_id and client_secret by logging in your peertube website and reaching the URL:
Configuration is in **peertube_secret** file.
You need your usual credentials and Peertube instance URL, in addition with API client_id and client_secret.
You can get client_id and client_secret by logging in your peertube instance and reaching the URL:
https://domain.example/api/v1/oauth-clients/local
You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)
*Alternatively, you can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)*
### Youtube
Configuration is in **youtube_secret.json** file.
Youtube uses combination of oauth and API access to identify.
**Credentials**
@ -88,7 +94,7 @@ 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))
Here are some demonstration of main usage you would like!
Here are some demonstration of main usage:
Upload a video:
```sh
@ -105,7 +111,7 @@ Provide a thumbnail:
python -m 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.:
Publish on Peertube only, while using a channel and a playlist, creating them if they do not exist:
```sh
python -m prismedia --file="yourvideo.mp4" --platform=peertube --channel="Cooking recipes" --playlist="Cake recipes" --channelCreate --playlistCreate
```
@ -131,9 +137,9 @@ python -m prismedia --help
## Enhanced use of NFO
Since Prismedia v0.9.0, the NFO system has been improved to allow hierarchical loading.
First of all, **if you already used nfo**, either with `--nfo` or by using `videoname.txt`, nothing changes :-)
First, **if you already used nfo**, either with `--nfo` or by using `videoname.txt`, nothing changes :-)
But you are now able to use a more flexible NFO system, by using priorities. This allow you to set some defaults to avoid recreating a full nfo for each video
But you are now able to use a more flexible NFO system, by using priorities. This allows you to set some defaults to avoid recreating a full nfo for each video
Basically, Prismedia will now load options in this order, using the last value found in case of conflict:
`nfo.txt < directory_name.txt < video_name.txt < command line NFO < command line argument`
@ -227,4 +233,4 @@ Available strict options:
Inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)
## Contributors
Thanks to: @Zykino, @meewan, @rigelk 😘
Thanks to: @LecygneNoir, @Zykino, @meewan, @rigelk 😘

+ 8
- 1
prismedia/__init__.py View File

@ -1,5 +1,12 @@
from future import standard_library
standard_library.install_aliases()
import logging
logger = logging.getLogger('Prismedia')
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s: %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
from . import upload
from . import genconfig

+ 11
- 2
prismedia/genconfig.py View File

@ -1,6 +1,10 @@
from os.path import join, abspath, isfile, dirname
from os.path import join, abspath, isfile, dirname, exists
from os import listdir
from shutil import copyfile
import logging
logger = logging.getLogger('Prismedia')
from . import utils
def genconfig():
@ -8,7 +12,12 @@ def genconfig():
files = [f for f in listdir(path) if isfile(join(path, f))]
for f in files:
copyfile(join(path, f), f)
final_f = f.replace(".sample", "")
if exists(final_f) and not utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?"):
continue
copyfile(join(path, f), final_f)
logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
if __name__ == '__main__':

+ 0
- 6
prismedia/upload.py View File

@ -110,12 +110,6 @@ import os
import datetime
import logging
logger = logging.getLogger('Prismedia')
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s: %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
from docopt import docopt

+ 9
- 0
prismedia/utils.py View File

@ -100,6 +100,15 @@ def getLanguage(language, platform):
return PEERTUBE_LANGUAGE[language.lower()]
def ask_overwrite(question):
while True:
reply = str(input(question + ' (Yes/[No]): ') or "No").lower().strip()
if reply[:1] == 'y':
return True
if reply[:1] == 'n':
return False
def remove_empty_kwargs(**kwargs):
good_kwargs = {}
if kwargs is not None:

+ 1
- 0
pyproject.toml View File

@ -44,6 +44,7 @@ urllib3 = "^1.22"
[tool.poetry.scripts]
prismedia = 'prismedia.upload:main'
prismedia-init = 'prismedia.genconfig:genconfig'
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Loading…
Cancel
Save