mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Merge remote-tracking branch 'zykino/feature/playlist' into feature/playlist
This commit is contained in:
commit
8d24bfa6a1
2 changed files with 12 additions and 6 deletions
|
@ -158,6 +158,8 @@ Languages:
|
||||||
- [x] thumbnail/preview
|
- [x] thumbnail/preview
|
||||||
- [x] multiple lines description (see [issue 4](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/4))
|
- [x] 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)
|
- [ ] add videos to playlist (YT & PT workflow: upload video, find playlist id, add video to playlist)
|
||||||
|
- [x] Peertube
|
||||||
|
- [ ] Youtube
|
||||||
- [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, [curl](https://linux.die.net/man/1/curl) and [jq](https://stedolan.github.io/jq/))
|
- [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/))
|
||||||
|
|
|
@ -48,8 +48,11 @@ def get_authenticated_service(secret):
|
||||||
return oauth
|
return oauth
|
||||||
|
|
||||||
|
|
||||||
def get_playlist_by_name(user_info, options):
|
def get_default_playlist(user_info):
|
||||||
|
return user_info['videoChannels'][0]['id']
|
||||||
|
|
||||||
|
|
||||||
|
def get_playlist_by_name(user_info, options):
|
||||||
for playlist in user_info["videoChannels"]:
|
for playlist in user_info["videoChannels"]:
|
||||||
if playlist['displayName'] == options.get('--playlist'):
|
if playlist['displayName'] == options.get('--playlist'):
|
||||||
return playlist['id']
|
return playlist['id']
|
||||||
|
@ -95,8 +98,8 @@ def upload_video(oauth, secret, options):
|
||||||
mimetypes.types_map[splitext(path)[1]])
|
mimetypes.types_map[splitext(path)[1]])
|
||||||
|
|
||||||
path = options.get('--file')
|
path = options.get('--file')
|
||||||
|
url = secret.get('peertube', 'peertube_url')
|
||||||
user_info = get_userinfo()
|
user_info = get_userinfo()
|
||||||
url = str(secret.get('peertube', 'peertube_url')).rstrip('/')
|
|
||||||
|
|
||||||
# We need to transform fields into tuple to deal with tags as
|
# We need to transform fields into tuple to deal with tags as
|
||||||
# MultipartEncoder does not support list refer
|
# MultipartEncoder does not support list refer
|
||||||
|
@ -107,7 +110,7 @@ def upload_video(oauth, secret, options):
|
||||||
("licence", "1"),
|
("licence", "1"),
|
||||||
("description", options.get('--description') or "default description"),
|
("description", options.get('--description') or "default description"),
|
||||||
("nsfw", str(int(options.get('--nsfw')) or "0")),
|
("nsfw", str(int(options.get('--nsfw')) or "0")),
|
||||||
("videofile", get_file(options.get('--file')))
|
("videofile", get_file(path))
|
||||||
]
|
]
|
||||||
|
|
||||||
if options.get('--tags'):
|
if options.get('--tags'):
|
||||||
|
@ -155,10 +158,11 @@ def upload_video(oauth, secret, options):
|
||||||
playlist_id = get_playlist_by_name(user_info, options)
|
playlist_id = get_playlist_by_name(user_info, options)
|
||||||
if not playlist_id and options.get('--playlistCreate'):
|
if not playlist_id and options.get('--playlistCreate'):
|
||||||
playlist_id = create_playlist(oauth, url, options)
|
playlist_id = create_playlist(oauth, url, options)
|
||||||
else:
|
elif not playlist_id:
|
||||||
playlist_id = user_info['id']
|
logging.warning("Playlist `" + options.get('--playlist') + "` is unknown, using default playlist.")
|
||||||
|
playlist_id = get_default_playlist(user_info)
|
||||||
else:
|
else:
|
||||||
playlist_id = user_info['id']
|
playlist_id = get_default_playlist(user_info)
|
||||||
fields.append(("channelId", str(playlist_id)))
|
fields.append(("channelId", str(playlist_id)))
|
||||||
|
|
||||||
multipart_data = MultipartEncoder(fields)
|
multipart_data = MultipartEncoder(fields)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue