Browse Source

move sample file into config submodule, genconfig command instead

pull/34/head
Romain Kerguelen 5 years ago
parent
commit
80a7f07194
Signed by untrusted user: rigelk GPG Key ID: EA12971B0E438F36
7 changed files with 28 additions and 3 deletions
  1. +2
    -1
      README.md
  2. +1
    -0
      prismedia/__init__.py
  3. +0
    -0
      prismedia/config/nfo_example.txt
  4. +0
    -0
      prismedia/config/peertube_secret.sample
  5. +0
    -0
      prismedia/config/youtube_secret.json.sample
  6. +15
    -0
      prismedia/genconfig.py
  7. +10
    -2
      prismedia/utils.py

+ 2
- 1
README.md View File

@ -28,7 +28,8 @@ poetry install # installs the dependency in a virtualenv specific to the project
## Configuration
Edit `peertube_secret` and `youtube_secret.json` with your credentials.
Generate sample files with `python -m prismedia.genconfig`. Edit
`peertube_secret` and `youtube_secret.json` with your credentials.
### Peertube

+ 1
- 0
prismedia/__init__.py View File

@ -1 +1,2 @@
from . import upload
from . import genconfig

nfo_example.txt → prismedia/config/nfo_example.txt View File


peertube_secret.sample → prismedia/config/peertube_secret.sample View File


youtube_secret.json.sample → prismedia/config/youtube_secret.json.sample View File


+ 15
- 0
prismedia/genconfig.py View File

@ -0,0 +1,15 @@
from os.path import join, abspath, isfile, dirname
from os import listdir
from shutil import copyfile
def genconfig():
path = join(dirname(__file__), 'config')
files = [f for f in listdir(path) if isfile(join(path, f))]
for f in files:
copyfile(join(path, f), f)
if __name__ == '__main__':
genconfig()

+ 10
- 2
prismedia/utils.py View File

@ -107,6 +107,7 @@ def remove_empty_kwargs(**kwargs):
good_kwargs[key] = value
return good_kwargs
def searchThumbnail(options):
video_directory = dirname(options.get('--file')) + "/"
# First, check for thumbnail based on videoname
@ -124,6 +125,7 @@ def searchThumbnail(options):
options['--thumbnail'] = video_directory + video_file + ".jpeg"
return options
# return the nfo as a RawConfigParser object
def loadNFO(options):
video_directory = dirname(options.get('--file')) + "/"
@ -168,10 +170,12 @@ def loadNFO(options):
logging.info("No suitable NFO found, skipping.")
return False
def parseNFO(options):
nfo = loadNFO(options)
if nfo:
# We need to check all options and replace it with the nfo value if not defined (None or False)
# We need to check all options and replace it with the nfo value if not
# defined (None or False)
for key, value in options.iteritems():
key = key.replace("-", "")
try:
@ -188,9 +192,11 @@ def parseNFO(options):
exit(1)
return options
def upcaseFirstLetter(s):
return s[0].upper() + s[1:]
def cleanString(toclean):
toclean = toclean.decode('utf-8')
toclean = unidecode.unidecode(toclean)
@ -198,10 +204,11 @@ def cleanString(toclean):
return cleaned
def decodeArgumentStrings(options, encoding):
# Python crash when decoding from UTF-8 to UTF-8, so we prevent this
if "utf-8" == encoding.lower():
return;
return
if options["--name"] is not None:
options["--name"] = options["--name"].decode(encoding)
@ -211,3 +218,4 @@ def decodeArgumentStrings(options, encoding):
if options["--tags"] is not None:
options["--tags"] = options["--tags"].decode(encoding)

Loading…
Cancel
Save