mirror of
https://github.com/alexta69/metube.git
synced 2025-04-04 12:47:38 +03:00
Merge pull request #335 from ArabCoders/master
Expose done/queue list as JSON endpoint
This commit is contained in:
commit
03d6edea5c
3 changed files with 21 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -46,3 +46,4 @@ Thumbs.db
|
|||
|
||||
|
||||
__pycache__
|
||||
.venv
|
||||
|
|
11
app/main.py
11
app/main.py
|
@ -132,6 +132,17 @@ async def delete(request):
|
|||
status = await (dqueue.cancel(ids) if where == 'queue' else dqueue.clear(ids))
|
||||
return web.Response(text=serializer.encode(status))
|
||||
|
||||
@routes.get(config.URL_PREFIX + 'history')
|
||||
async def history(request):
|
||||
history = { 'done': [], 'queue': []}
|
||||
|
||||
for _ ,v in dqueue.queue.saved_items():
|
||||
history['queue'].append(v)
|
||||
for _ ,v in dqueue.done.saved_items():
|
||||
history['done'].append(v)
|
||||
|
||||
return web.Response(text=serializer.encode(history))
|
||||
|
||||
@sio.event
|
||||
async def connect(sid, environ):
|
||||
await sio.emit('all', serializer.encode(dqueue.get()), to=sid)
|
||||
|
|
|
@ -243,6 +243,9 @@ class DownloadQueue:
|
|||
return dldirectory, None
|
||||
|
||||
async def __add_entry(self, entry, quality, format, folder, custom_name_prefix, already):
|
||||
if not entry:
|
||||
return {'status': 'error', 'msg': "Invalid/empty data was given."}
|
||||
|
||||
etype = entry.get('_type') or 'video'
|
||||
if etype == 'playlist':
|
||||
entries = entry['entries']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue