v1.0.1 로그 좀 더 상세히 찍도록 수정

This commit is contained in:
joyfuI
2020-02-10 01:06:11 +09:00
parent 47b3f615eb
commit 847ab7fb7d
4 changed files with 30 additions and 25 deletions

View File

@@ -15,7 +15,6 @@ v1.0.0
* 목록에서 진행률 표시 추가 * 목록에서 진행률 표시 추가
v0.1.1 v0.1.1
* ~~윈도우 환경 지원 추가~~
* 다운로드 실패 시 임시파일 삭제가 안 되는 문제 수정 * 다운로드 실패 시 임시파일 삭제가 안 되는 문제 수정
v0.1.0 v0.1.0

View File

@@ -1 +1 @@
{"more": "", "version": "1.0.0", "name": "youtube-dl", "developer": "joyfuI", "home": "https://github.com/joyfuI/youtube-dl", "description": "\uc720\ud29c\ube0c, \ub124\uc774\ubc84TV \ub4f1 \ub3d9\uc601\uc0c1 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ub3d9\uc601\uc0c1 \ub2e4\uc6b4\ub85c\ub4dc", "icon": "", "category_name": "vod"} {"more": "", "version": "1.0.1", "name": "youtube-dl", "developer": "joyfuI", "home": "https://github.com/joyfuI/youtube-dl", "description": "\uc720\ud29c\ube0c, \ub124\uc774\ubc84TV \ub4f1 \ub3d9\uc601\uc0c1 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ub3d9\uc601\uc0c1 \ub2e4\uc6b4\ub85c\ub4dc", "icon": "", "category_name": "vod"}

View File

@@ -78,28 +78,32 @@ class Youtube_dl(object):
self.status = Status.START self.status = Status.START
def run(self): def run(self):
info_dict = Youtube_dl.get_info_dict(self.url) # 동영상 정보 가져오기 try:
if info_dict is None: # 가져오기 실패 info_dict = Youtube_dl.get_info_dict(self.url) # 동영상 정보 가져오기
self.status = Status.ERROR if info_dict is None: # 가져오기 실패
return self.status = Status.ERROR
self.extractor = info_dict['extractor'] return
self.title = info_dict['title'] self.extractor = info_dict['extractor']
self.uploader = info_dict['uploader'] self.title = info_dict['title']
self.uploader_url = info_dict['uploader_url'] self.uploader = info_dict['uploader']
ydl_opts = { self.uploader_url = info_dict['uploader_url']
'logger': MyLogger(), ydl_opts = {
'progress_hooks': [self.my_hook], 'logger': MyLogger(),
# 'match_filter': self.match_filter_func, 'progress_hooks': [self.my_hook],
'outtmpl': os.path.join(self.temp_path, self.filename) # 'match_filter': self.match_filter_func,
} 'outtmpl': os.path.join(self.temp_path, self.filename)
with youtube_dl.YoutubeDL(ydl_opts) as ydl: }
ydl.download([self.url]) with youtube_dl.YoutubeDL(ydl_opts) as ydl:
if self.status == Status.FINISHED: # 다운로드 성공 ydl.download([self.url])
for i in glob.glob(self.temp_path + '/*'): if self.status == Status.FINISHED: # 다운로드 성공
shutil.move(i, self.save_path) # 파일 이동 for i in glob.glob(self.temp_path + '/*'):
self.status = Status.COMPLETED shutil.move(i, self.save_path) # 파일 이동
shutil.rmtree(self.temp_path) # 임시폴더 삭제 self.status = Status.COMPLETED
self.end_time = datetime.now() shutil.rmtree(self.temp_path) # 임시폴더 삭제
self.end_time = datetime.now()
except Exception as e:
logger.error('Exception:%s', e)
logger.error(traceback.format_exc())
def stop(self): def stop(self):
self.status = Status.STOP self.status = Status.STOP
@@ -120,6 +124,8 @@ class Youtube_dl(object):
with youtube_dl.YoutubeDL(ydl_opts) as ydl: with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url]) ydl.download([url])
except Exception as e: except Exception as e:
logger.error('Exception:%s', e)
logger.error(traceback.format_exc())
return None return None
return json.loads(Youtube_dl._last_msg) return json.loads(Youtube_dl._last_msg)

View File

@@ -33,7 +33,7 @@ def plugin_unload():
Logic.plugin_unload() Logic.plugin_unload()
plugin_info = { plugin_info = {
'version': '1.0.0', 'version': '1.0.1',
'name': 'youtube-dl', 'name': 'youtube-dl',
'category_name': 'vod', 'category_name': 'vod',
'icon': '', 'icon': '',