Browse Source

Merge branch 'release/v0.5'

pull/34/head
LecygneNoir 6 years ago
parent
commit
e4e7abb39d
6 changed files with 42 additions and 13 deletions
  1. +11
    -0
      CHANGELOG.md
  2. +6
    -3
      README.md
  3. +2
    -3
      lib/pt_upload.py
  4. +19
    -6
      lib/utils.py
  5. +3
    -0
      nfo_example.txt
  6. +1
    -1
      prismedia_upload.py

+ 11
- 0
CHANGELOG.md View File

@ -0,0 +1,11 @@
# Prismedia v0.5
## Features
- plan your Peertube videos! Stable release
- Support for Peertube beta4
- More examples in NFO
- Better support for multilines descriptions
## Fix
- Display datetime for output
- plan video only if upload is successful

+ 6
- 3
README.md View File

@ -17,6 +17,7 @@ Search in your package manager, otherwise use ``pip install --upgrade``
For Peertube and if you want to use the publishAt option, you also need some utilities on you local system
- [atd](https://linux.die.net/man/8/atd) daemon
- [curl](https://linux.die.net/man/1/curl)
- [jq](https://stedolan.github.io/jq/)
## Configuration
@ -110,7 +111,7 @@ Options:
--publishAt=DATE Publish the video at the given DATE using local server timezone.
DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00
DATE should be in the future
For Peertube, requires the "atd" and "curl utilities installed on the system
For Peertube, requires the "atd", "curl" and "jq" utilities installed on the system
-h --help Show this help.
--version Show version.
@ -144,10 +145,12 @@ Languages:
- [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
- [x] nsfw (Peertube only as Youtube API does not support it)
- [x] set default language
- ~~thumbnail/preview~~ Canceled, waiting for Youtube's API support
- [ ] thumbnail/preview (YT workflow: upload video, upload thumbnail, add thumbnail to video)
- [ ] multiple lines description (see [issue 4](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/4))
- [ ] add videos to playlist (YT & PT workflow: upload video, find playlist id, add video to playlist)
- [x] Use a config file (NFO) file to retrieve videos arguments
- [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
- [x] Add publishAt option to plan your videos (need the [atd](https://linux.die.net/man/8/atd) daemon and [curl](https://linux.die.net/man/1/curl))
- [x] Add publishAt option to plan your videos (need the [atd](https://linux.die.net/man/8/atd) daemon, [curl](https://linux.die.net/man/1/curl) and [jq](https://stedolan.github.io/jq/))
- [ ] 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

+ 2
- 3
lib/pt_upload.py View File

@ -123,14 +123,13 @@ def upload_video(oauth, secret, options):
template = ('Peertube : Video was successfully uploaded.\n'
'Watch it at %s/videos/watch/%s.')
logging.info(template % (url, uuid))
if options.get('--publishAt'):
utils.publishAt(str(options.get('--publishAt')), oauth, url, idvideo, secret)
else:
logging.error(('Peertube : The upload failed with an unexpected response: '
'%s') % response)
exit(1)
if options.get('--publishAt'):
utils.publishAt(str(options.get('--publishAt')), oauth, url, idvideo)
def run(options):
secret = RawConfigParser()

+ 19
- 6
lib/utils.py View File

@ -169,7 +169,7 @@ def upcaseFirstLetter(s):
return s[0].upper() + s[1:]
def publishAt(publishAt, oauth, url, idvideo):
def publishAt(publishAt, oauth, url, idvideo, secret):
try:
FNULL = open(devnull, 'w')
check_call(["at", "-V"], stdout=FNULL, stderr=STDOUT)
@ -182,19 +182,32 @@ def publishAt(publishAt, oauth, url, idvideo):
except CalledProcessError:
logging.error("You need to install the curl command line to use the publishAt option.")
exit(1)
try:
FNULL = open(devnull, 'w')
check_call(["jq", "-V"], stdout=FNULL, stderr=STDOUT)
except CalledProcessError:
logging.error("You need to install the jq command line to use the publishAt option.")
exit(1)
time = publishAt.split("T")
# Remove leading seconds that atd does not manage
if time[1].count(":") == 2:
time[1] = time[1][:-3]
atTime = time[1] + " " + time[0]
token=str(oauth.__dict__['_client'].__dict__['access_token'])
refresh_token=str(oauth.__dict__['_client'].__dict__['refresh_token'])
atFile = "/tmp/peertube_" + idvideo + "_" + publishAt + ".at"
try:
file = open(atFile,"w")
file.write("curl '" + url + "/api/v1/videos/" + idvideo + "' -X PUT -H 'Authorization: Bearer " + token + "' -H 'Content-Type: multipart/form-data' -F 'privacy=1'")
file.write(" ") # atd needs an empty line at the end of the file to load...
file.close()
openfile = open(atFile,"w")
openfile.write('token=$(curl -X POST -d "client_id=' + str(secret.get('peertube', 'client_id')) +
'&client_secret=' + str(secret.get('peertube', 'client_secret')) +
'&grant_type=refresh_token&refresh_token=' + str(refresh_token) +
'" "' + url + '/api/v1/users/token" | jq -r .access_token)')
openfile.write("\n")
openfile.write('curl "' + url + '/api/v1/videos/' + idvideo +
'" -X PUT -H "Authorization: Bearer ${token}"' +
' -H "Content-Type: multipart/form-data" -F "privacy=1"')
openfile.write("\n ") # atd needs an empty line at the end of the file to load...
openfile.close()
except Exception as e:
if hasattr(e, 'message'):
logging.error("Error: " + str(e.message))

+ 3
- 0
nfo_example.txt View File

@ -8,6 +8,9 @@
[video]
name = videoname
description = Your complete video description
Multilines description
should be wrote with a blank space
at the beginning of the line :)
tags = list of tags, comma separated
mt = True
category = Films

+ 1
- 1
prismedia_upload.py View File

@ -86,7 +86,7 @@ except ImportError:
'see https://github.com/ahupp/python-magic\n')
exit(1)
VERSION = "prismedia v0.4"
VERSION = "prismedia v0.5"
VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
VALID_CATEGORIES = (

Loading…
Cancel
Save