mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 17:39:16 +02:00
Improve genconfig system and documentation for easier use, cf #55
This commit is contained in:
parent
cdef038323
commit
1a006f3b6c
4 changed files with 38 additions and 19 deletions
28
README.md
28
README.md
|
@ -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.
|
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
|
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)
|
(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
|
poetry install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Generate sample files with `python -m prismedia.genconfig`.
|
Generate configuration files by running `prismedia-init`.
|
||||||
Then rename and edit `peertube_secret` and `youtube_secret.json` with your credentials. (see below)
|
|
||||||
|
Then, edit them to fill your credential as explained below.
|
||||||
|
|
||||||
### Peertube
|
### Peertube
|
||||||
Set your credentials, peertube server URL.
|
Configuration is in **peertube_secret** file.
|
||||||
You can get client_id and client_secret by logging in your peertube website and reaching the URL:
|
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
|
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
|
### Youtube
|
||||||
|
Configuration is in **youtube_secret.json** file.
|
||||||
Youtube uses combination of oauth and API access to identify.
|
Youtube uses combination of oauth and API access to identify.
|
||||||
|
|
||||||
**Credentials**
|
**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.
|
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))
|
**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:
|
Upload a video:
|
||||||
```sh
|
```sh
|
||||||
|
@ -105,7 +111,7 @@ Provide a thumbnail:
|
||||||
python -m prismedia --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg"
|
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
|
```sh
|
||||||
python -m prismedia --file="yourvideo.mp4" --platform=peertube --channel="Cooking recipes" --playlist="Cake recipes" --channelCreate --playlistCreate
|
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
|
## Enhanced use of NFO
|
||||||
Since Prismedia v0.9.0, the NFO system has been improved to allow hierarchical loading.
|
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:
|
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`
|
`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)
|
Inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
Thanks to: @Zykino, @meewan, @rigelk 😘
|
Thanks to: @LecygneNoir, @Zykino, @meewan, @rigelk 😘
|
|
@ -1,6 +1,17 @@
|
||||||
from os.path import join, abspath, isfile, dirname
|
from os.path import join, abspath, isfile, dirname, exists
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger('Prismedia')
|
||||||
|
|
||||||
|
|
||||||
|
def overwrite_or_not(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 genconfig():
|
def genconfig():
|
||||||
|
@ -8,7 +19,14 @@ def genconfig():
|
||||||
files = [f for f in listdir(path) if isfile(join(path, f))]
|
files = [f for f in listdir(path) if isfile(join(path, f))]
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
copyfile(join(path, f), f)
|
final_f = f.replace(".sample", "")
|
||||||
|
overwrite = True
|
||||||
|
if exists(final_f):
|
||||||
|
overwrite = overwrite_or_not(final_f + " already exists. Do you want to overwrite it?")
|
||||||
|
|
||||||
|
if overwrite:
|
||||||
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -110,12 +110,6 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger('Prismedia')
|
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
|
from docopt import docopt
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ urllib3 = "^1.22"
|
||||||
|
|
||||||
[tool.poetry.scripts]
|
[tool.poetry.scripts]
|
||||||
prismedia = 'prismedia.upload:main'
|
prismedia = 'prismedia.upload:main'
|
||||||
|
prismedia-init = 'prismedia.genconfig:genconfig'
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry>=0.12"]
|
requires = ["poetry>=0.12"]
|
||||||
build-backend = "poetry.masonry.api"
|
build-backend = "poetry.masonry.api"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue