Skip to content

Commit

Permalink
Fullly support bestvideo + bestaudio format.
Browse files Browse the repository at this point in the history
For some high quality videos, video and audio files will be downloaded
separately if using `bestvideo+bestaudio` format.
  • Loading branch information
d0u9 committed Apr 18, 2018
1 parent 083769d commit 9f534bf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This project is writen under the **python 3.6**, I haven't test the codes in
any other python versions. So, I hightly recommend you to use python 3.6 to
avoid any troubles.

Also, we need **[ffmpeg](https://www.ffmpeg.org/download.html)** for post
processing. Lack of ffmpeg may case some funtions not working.

# Install

Expand Down
9 changes: 6 additions & 3 deletions youtube_dl_webui/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ def event_progress(cls, svr, event, data, arg):
cls._task_mgr.progress_update(tid, data)
except TaskInexistenceError:
cls.logger.error('Cannot update progress, task does not exist')
else:
if data['status'] == 'finished':
cls._task_mgr.finish_task(tid)

@classmethod
def event_worker_done(cls, svr, event, data, arg):
tid, data = data['tid'], data['data']
cls._task_mgr.finish_task(tid)


def load_conf_from_file(cmd_args):
Expand Down Expand Up @@ -275,6 +277,7 @@ def __init__(self, cmd_args=None):
self.msg_mgr.reg_event('log', WorkMsgDispatcher.event_log)
self.msg_mgr.reg_event('progress', WorkMsgDispatcher.event_progress)
self.msg_mgr.reg_event('fatal', WorkMsgDispatcher.event_fatal)
self.msg_mgr.reg_event('worker_done',WorkMsgDispatcher.event_worker_done)

self.server = Server(web_cli, self.conf['server']['host'], self.conf['server']['port'])

Expand Down
6 changes: 1 addition & 5 deletions youtube_dl_webui/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,7 @@ def delete_task(self, tid):
if row is None:
raise TaskInexistenceError('')

dl_file = None
if row['tmpfilename'] != '':
dl_file = row['tmpfilename']
elif row['filename'] != '':
dl_file = row['filename']
dl_file = row['filename']

self.db.execute('DELETE FROM task_status WHERE tid=(?)', (tid, ))
self.db.execute('DELETE FROM task_info WHERE tid=(?)', (tid, ))
Expand Down
12 changes: 9 additions & 3 deletions youtube_dl_webui/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import json
import glob

from time import time
from collections import deque
Expand Down Expand Up @@ -211,9 +212,14 @@ def delete_task(self, tid, del_file=False):
raise TaskInexistenceError(e.msg)

if del_file and dl_file is not None:
abs_dl_file = os.path.join(os.getcwd(), dl_file)
self.logger.debug('delete file: %s' %(abs_dl_file))
os.remove(abs_dl_file)
file_wo_ext, ext = dl_file, None
while ext != '':
file_wo_ext, ext = os.path.splitext(file_wo_ext)

for fname in os.listdir(os.getcwd()):
if fname.startswith(file_wo_ext):
self.logger.debug('delete file: %s' %(fname))
os.remove(os.path.join(os.getcwd(), fname))

def query(self, tid, exerpt=True):
db_ret = self._db.query_task(tid)
Expand Down
2 changes: 2 additions & 0 deletions youtube_dl_webui/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def run(self):
event_handler = FatalEvent(self.tid, self.msg_cli)
event_handler.invalid_url(self.url);

self.msg_cli.put('worker_done', {'tid': self.tid, 'data': {}})

def stop(self):
self.logger.info('Terminating Process ...')
self.terminate()
Expand Down

0 comments on commit 9f534bf

Please sign in to comment.