mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-06 10:39:58 +02:00
Merge branch 'release/v0.5'
This commit is contained in:
commit
e4e7abb39d
6 changed files with 42 additions and 13 deletions
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal 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
|
|
@ -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
|
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
|
- [atd](https://linux.die.net/man/8/atd) daemon
|
||||||
- [curl](https://linux.die.net/man/1/curl)
|
- [curl](https://linux.die.net/man/1/curl)
|
||||||
|
- [jq](https://stedolan.github.io/jq/)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ Options:
|
||||||
--publishAt=DATE Publish the video at the given DATE using local server timezone.
|
--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 on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00
|
||||||
DATE should be in the future
|
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.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
|
|
||||||
|
@ -144,10 +145,12 @@ Languages:
|
||||||
- [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
|
- [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] nsfw (Peertube only as Youtube API does not support it)
|
||||||
- [x] set default language
|
- [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] 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] 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
|
- [ ] 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)
|
- [ ] Usable on Desktop (Linux and/or Windows and/or MacOS)
|
||||||
- [ ] Graphical User Interface
|
- [ ] Graphical User Interface
|
||||||
|
|
|
@ -123,14 +123,13 @@ def upload_video(oauth, secret, options):
|
||||||
template = ('Peertube : Video was successfully uploaded.\n'
|
template = ('Peertube : Video was successfully uploaded.\n'
|
||||||
'Watch it at %s/videos/watch/%s.')
|
'Watch it at %s/videos/watch/%s.')
|
||||||
logging.info(template % (url, uuid))
|
logging.info(template % (url, uuid))
|
||||||
|
if options.get('--publishAt'):
|
||||||
|
utils.publishAt(str(options.get('--publishAt')), oauth, url, idvideo, secret)
|
||||||
else:
|
else:
|
||||||
logging.error(('Peertube : The upload failed with an unexpected response: '
|
logging.error(('Peertube : The upload failed with an unexpected response: '
|
||||||
'%s') % response)
|
'%s') % response)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if options.get('--publishAt'):
|
|
||||||
utils.publishAt(str(options.get('--publishAt')), oauth, url, idvideo)
|
|
||||||
|
|
||||||
|
|
||||||
def run(options):
|
def run(options):
|
||||||
secret = RawConfigParser()
|
secret = RawConfigParser()
|
||||||
|
|
25
lib/utils.py
25
lib/utils.py
|
@ -169,7 +169,7 @@ def upcaseFirstLetter(s):
|
||||||
return s[0].upper() + s[1:]
|
return s[0].upper() + s[1:]
|
||||||
|
|
||||||
|
|
||||||
def publishAt(publishAt, oauth, url, idvideo):
|
def publishAt(publishAt, oauth, url, idvideo, secret):
|
||||||
try:
|
try:
|
||||||
FNULL = open(devnull, 'w')
|
FNULL = open(devnull, 'w')
|
||||||
check_call(["at", "-V"], stdout=FNULL, stderr=STDOUT)
|
check_call(["at", "-V"], stdout=FNULL, stderr=STDOUT)
|
||||||
|
@ -182,19 +182,32 @@ def publishAt(publishAt, oauth, url, idvideo):
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
logging.error("You need to install the curl command line to use the publishAt option.")
|
logging.error("You need to install the curl command line to use the publishAt option.")
|
||||||
exit(1)
|
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")
|
time = publishAt.split("T")
|
||||||
# Remove leading seconds that atd does not manage
|
# Remove leading seconds that atd does not manage
|
||||||
if time[1].count(":") == 2:
|
if time[1].count(":") == 2:
|
||||||
time[1] = time[1][:-3]
|
time[1] = time[1][:-3]
|
||||||
|
|
||||||
atTime = time[1] + " " + time[0]
|
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"
|
atFile = "/tmp/peertube_" + idvideo + "_" + publishAt + ".at"
|
||||||
try:
|
try:
|
||||||
file = open(atFile,"w")
|
openfile = 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'")
|
openfile.write('token=$(curl -X POST -d "client_id=' + str(secret.get('peertube', 'client_id')) +
|
||||||
file.write(" ") # atd needs an empty line at the end of the file to load...
|
'&client_secret=' + str(secret.get('peertube', 'client_secret')) +
|
||||||
file.close()
|
'&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:
|
except Exception as e:
|
||||||
if hasattr(e, 'message'):
|
if hasattr(e, 'message'):
|
||||||
logging.error("Error: " + str(e.message))
|
logging.error("Error: " + str(e.message))
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
[video]
|
[video]
|
||||||
name = videoname
|
name = videoname
|
||||||
description = Your complete video description
|
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
|
tags = list of tags, comma separated
|
||||||
mt = True
|
mt = True
|
||||||
category = Films
|
category = Films
|
||||||
|
|
|
@ -86,7 +86,7 @@ except ImportError:
|
||||||
'see https://github.com/ahupp/python-magic\n')
|
'see https://github.com/ahupp/python-magic\n')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
VERSION = "prismedia v0.4"
|
VERSION = "prismedia v0.5"
|
||||||
|
|
||||||
VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
|
VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
|
||||||
VALID_CATEGORIES = (
|
VALID_CATEGORIES = (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue