diff --git a/README.md b/README.md index 969d6f5..13cec2f 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ API에선 직접 비트레이트를 설정할 수 있습니다. `preferedformat` | 변환할 비디오 포맷. 가능한 포맷은 https://ffmpeg.org/general.html#File-Formats 참고. 미지정 시 변환하지 않음 | X | String `preferredcodec` | 추출할 오디오 코덱. 가능한 값은 `"best"`, `"mp3"`, `"aac"`, `"flac"`, `"m4a"`, `"opus"`, `"vorbis"`, `"wav"`. 미지정 시 추출하지 않음 | X | String `preferredquality` | 추출한 오디오의 비트레이트. 0 ~ 9 사이의 VBR 퀄리티 값(0에 가까울수록 좋음) 혹은 특정 비트레이트 값. `preferredcodec` 키가 있을 때만 유효. 기본값: `192` | X | Integer +`archive` | 다운로드한 동영상의 ID를 기록할 파일 경로. 파일이 이미 있을 경우 이미 다운로드한 동영상은 다운로드 하지 않음. 미지정 시 기록하지 않음 | X | String `start` | 다운로드 준비 후 바로 다운로드를 시작할지 여부. 기본값: `false` | X | Boolean #### Response 키 | 설명 | 타입 @@ -127,10 +128,16 @@ API에선 직접 비트레이트를 설정할 수 있습니다. `temp_path` | 임시 폴더 경로 | String `save_path` | 저장 폴더 경로 | String -`start_time` 키와 `end_time` 키에 들어있는 시간은 "년 월 일 시 분 초" 형식으로 공백으로 분리된 숫자들이 모여있는 문자열입니다. +`start_time` 키와 `end_time` 키에 들어있는 시간은 "YYYY-MM-DDThh:mm:ss" 형식의 문자열입니다. 물론 해당 정보가 없으면 null입니다. ## Changelog +v1.5.0 +* 프록시 설정 추가 +* API에 archive 추가 + download-archive 기능으로 다운로드한 동영상의 ID를 기록하여 이미 다운로드한 동영상은 다운로드 하지 않는 옵션입니다. +* status API의 시간 형식 변경 (ISO 8601) + v1.4.2 * --rm-cache-dir 옵션 추가 * 플러그인 최초 설치 시 작동 안 되는 문제 수정 diff --git a/info.json b/info.json index 8fecf9c..db851b6 100644 --- a/info.json +++ b/info.json @@ -1 +1 @@ -{"description": "\uc720\ud29c\ube0c, \ub124\uc774\ubc84TV \ub4f1 \ub3d9\uc601\uc0c1 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ub3d9\uc601\uc0c1 \ub2e4\uc6b4\ub85c\ub4dc", "name": "youtube-dl", "more": "", "version": "1.4.2", "home": "https://github.com/joyfuI/youtube-dl", "category_name": "vod", "developer": "joyfuI"} \ No newline at end of file +{"description": "\uc720\ud29c\ube0c, \ub124\uc774\ubc84TV \ub4f1 \ub3d9\uc601\uc0c1 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ub3d9\uc601\uc0c1 \ub2e4\uc6b4\ub85c\ub4dc", "name": "youtube-dl", "more": "", "version": "1.5.0", "home": "https://github.com/joyfuI/youtube-dl", "category_name": "vod", "developer": "joyfuI"} \ No newline at end of file diff --git a/logic.py b/logic.py index 8923fae..995910a 100644 --- a/logic.py +++ b/logic.py @@ -23,6 +23,7 @@ class Logic(object): 'temp_path': os.path.join(path_data, 'download_tmp'), 'save_path': os.path.join(path_data, 'download'), 'default_filename': '%(title)s-%(id)s.%(ext)s', + 'proxy': '', 'activate_cors': False } diff --git a/my_youtube_dl.py b/my_youtube_dl.py index f258806..bcc10a7 100644 --- a/my_youtube_dl.py +++ b/my_youtube_dl.py @@ -43,7 +43,7 @@ class Youtube_dl(object): _index = 0 _last_msg = '' - def __init__(self, plugin, url, filename, temp_path, save_path, format_code=None, postprocessor=None): + def __init__(self, plugin, url, filename, temp_path, save_path, format_code=None, postprocessor=None, proxy='', archive=None): self.plugin = plugin self.url = url self.filename = filename @@ -55,6 +55,8 @@ class Youtube_dl(object): self.save_path = save_path self.format_code = format_code self.postprocessor = postprocessor + self.proxy = proxy + self.archive = archive self.index = Youtube_dl._index Youtube_dl._index += 1 self._status = Status.READY @@ -111,6 +113,10 @@ class Youtube_dl(object): ydl_opts['format'] = self.format_code if self.postprocessor is not None: ydl_opts['postprocessors'] = self.postprocessor + if not self.proxy: + ydl_opts['proxy'] = self.proxy + if self.archive is not None: + ydl_opts['download_archive'] = self.archive with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([self.url]) if self.status == Status.FINISHED: # 다운로드 성공 diff --git a/plugin.py b/plugin.py index 301f7ab..ca48c47 100644 --- a/plugin.py +++ b/plugin.py @@ -34,7 +34,7 @@ menu = { } plugin_info = { - 'version': '1.4.2', + 'version': '1.5.0', 'name': 'youtube-dl', 'category_name': 'vod', 'developer': 'joyfuI', @@ -105,6 +105,7 @@ def ajax(sub): save_path = ModelSetting.get('save_path') format_code = request.form['format'] if request.form['format'] else None postprocessor = request.form['postprocessor'] if request.form['postprocessor'] else None + proxy = ModelSetting.get('proxy') video_convertor, extract_audio = LogicNormal.get_postprocessor() if postprocessor in video_convertor: postprocessor = [{ @@ -117,7 +118,7 @@ def ajax(sub): 'preferredcodec': postprocessor, 'preferredquality': '192' }] - youtube_dl = Youtube_dl(package_name, url, filename, temp_path, save_path, format_code, postprocessor) + youtube_dl = Youtube_dl(package_name, url, filename, temp_path, save_path, format_code, postprocessor, proxy) LogicNormal.youtube_dl_list.append(youtube_dl) # 리스트 추가 youtube_dl.start() socketio_emit('add', youtube_dl) @@ -179,6 +180,7 @@ def api(sub): preferedformat = request.form.get('preferedformat', None) preferredcodec = request.form.get('preferredcodec', None) preferredquality = request.form.get('preferredquality', 192) + archive = request.form.get('archive', None) start = request.form.get('start', False) ret = { 'errorCode': 0, @@ -202,7 +204,8 @@ def api(sub): 'preferredcodec': preferredcodec, 'preferredquality': str(preferredquality) }) - youtube_dl = Youtube_dl(plugin, url, filename, temp_path, save_path, format_code, postprocessor) + proxy = ModelSetting.get('proxy') + youtube_dl = Youtube_dl(plugin, url, filename, temp_path, save_path, format_code, postprocessor, proxy, archive) youtube_dl.key = key LogicNormal.youtube_dl_list.append(youtube_dl) # 리스트 추가 ret['index'] = youtube_dl.index @@ -274,8 +277,8 @@ def api(sub): if youtube_dl.key != key: return LogicNormal.abort(ret, 4) # 키가 일치하지 않음 ret['status'] = youtube_dl.status.name - ret['start_time'] = youtube_dl.start_time.strftime('%Y %m %d %H %M %S') if youtube_dl.start_time is not None else None - ret['end_time'] = youtube_dl.end_time.strftime('%Y %m %d %H %M %S') if youtube_dl.end_time is not None else None + ret['start_time'] = youtube_dl.start_time.strftime('%Y-%m-%dT%H:%M:%S') if youtube_dl.start_time is not None else None + ret['end_time'] = youtube_dl.end_time.strftime('%Y-%m-%dT%H:%M:%S') if youtube_dl.end_time is not None else None ret['temp_path'] = youtube_dl.temp_path ret['save_path'] = youtube_dl.save_path return jsonify(ret) diff --git a/templates/youtube-dl_download.html b/templates/youtube-dl_download.html index cc2d775..6012cbd 100644 --- a/templates/youtube-dl_download.html +++ b/templates/youtube-dl_download.html @@ -41,7 +41,7 @@