v2.0.0 youtube-dlc 추가
This commit is contained in:
21
README.md
21
README.md
@@ -1,5 +1,5 @@
|
|||||||
# youtube-dl_sjva
|
# youtube-dl_sjva
|
||||||
[SJVA](https://sjva.me/) 용 [youtube-dl](https://ytdl-org.github.io/youtube-dl/) 플러그인입니다.
|
[SJVA](https://sjva.me/) 용 [youtube-dl](https://youtube-dl.org/) 플러그인입니다.
|
||||||
SJVA에서 유튜브, 네이버TV 등 동영상 사이트 영상을 다운로드할 수 있습니다.
|
SJVA에서 유튜브, 네이버TV 등 동영상 사이트 영상을 다운로드할 수 있습니다.
|
||||||
|
|
||||||
## 설치
|
## 설치
|
||||||
@@ -7,16 +7,14 @@ SJVA에서 "시스템 → 플러그인 → 플러그인 수동 설치" 칸에
|
|||||||
`https://github.com/joyfuI/youtube-dl`
|
`https://github.com/joyfuI/youtube-dl`
|
||||||
|
|
||||||
## 잡담
|
## 잡담
|
||||||
시놀로지 docker 환경에서 테스트했습니다.
|
시놀로지 docker 환경에서 테스트했습니다.
|
||||||
|
|
||||||
다른 분들이 만든 플러그인을 참고하며 주먹구구식으로 만들었습니다;;
|
API를 제공합니다. 다른 플러그인에서 동영상 정보나 다운로드를 요청할 수 있습니다.
|
||||||
|
다른 플러그인이 멋대로 다운로드를 중지할 수 없도록 다운로드를 요청할 때 임의의 키를 넘겨받습니다. 이 중지 요청 시 키가 일치해야 요청이 실행됩니다.
|
||||||
|
과연 이걸로 뭔가를 만드실 분이 계실지...
|
||||||
|
|
||||||
API도 제공합니다. 다른 플러그인에서 동영상 정보나 다운로드를 요청할 수 있습니다.
|
[youtube-dl](https://github.com/ytdl-org/youtube-dl)의 DMCA 테이크다운 이후, 업데이트 속도가 느려진 것 같아서 youtube-dl의 포크 프로젝트인 [youtube-dlc](https://github.com/blackjack4494/yt-dlc)를 추가했습니다.
|
||||||
다른 플러그인이 멋대로 다운로드를 중지할 수 없도록 다운로드를 요청할 때 임의의 키를 넘겨 받습니다. 이 중지 요청 시 키가 일치해야 요청이 실행됩니다.
|
설정에서 취향껏 설정해서 사용하시면 됩니다.
|
||||||
과연 이걸로 뭔가를 만드실 분이 계실지...
|
|
||||||
|
|
||||||
일반적인 유튜브 오디오 비트레이트가 192kbps라서 오디오 추출 시 비트레이트를 192kbps로 설정했습니다.
|
|
||||||
API에선 직접 비트레이트를 설정할 수 있습니다.
|
|
||||||
|
|
||||||
## API
|
## API
|
||||||
### 공통사항
|
### 공통사항
|
||||||
@@ -78,7 +76,6 @@ API에선 직접 비트레이트를 설정할 수 있습니다.
|
|||||||
`start` | 다운로드 준비 후 바로 다운로드를 시작할지 여부. 기본값: `false` | X | Boolean
|
`start` | 다운로드 준비 후 바로 다운로드를 시작할지 여부. 기본값: `false` | X | Boolean
|
||||||
|
|
||||||
`dateafter` 키에 넣을 수 있는 날짜는 `YYYYMMDD` 또는 `(now|today)[+-][0-9](day|week|month|year)(s)?` 형식의 문자열입니다.
|
`dateafter` 키에 넣을 수 있는 날짜는 `YYYYMMDD` 또는 `(now|today)[+-][0-9](day|week|month|year)(s)?` 형식의 문자열입니다.
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
키 | 설명 | 타입
|
키 | 설명 | 타입
|
||||||
--- | --- | ---
|
--- | --- | ---
|
||||||
@@ -135,6 +132,10 @@ API에선 직접 비트레이트를 설정할 수 있습니다.
|
|||||||
물론 해당 정보가 없으면 null입니다.
|
물론 해당 정보가 없으면 null입니다.
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
v2.0.0
|
||||||
|
* youtube-dlc 추가
|
||||||
|
사용할 youtube-dl 패키지를 선택할 수 있습니다. 설정 변경 후 재시작해야 적용됩니다.
|
||||||
|
|
||||||
v1.7.0
|
v1.7.0
|
||||||
* Python 3 지원
|
* Python 3 지원
|
||||||
Python 2를 유지한 채로 Python 3 지원을 추가했습니다.
|
Python 2를 유지한 채로 Python 3 지원을 추가했습니다.
|
||||||
|
|||||||
@@ -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.7.0", "home": "https://github.com/joyfuI/youtube-dl", "category_name": "vod", "developer": "joyfuI"}
|
{"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": "2.0.0", "home": "https://github.com/joyfuI/youtube-dl", "category_name": "vod", "developer": "joyfuI"}
|
||||||
7
logic.py
7
logic.py
@@ -15,12 +15,14 @@ from framework.util import Util
|
|||||||
|
|
||||||
# 패키지
|
# 패키지
|
||||||
from .plugin import logger, package_name
|
from .plugin import logger, package_name
|
||||||
|
from .logic_normal import LogicNormal
|
||||||
from .model import ModelSetting
|
from .model import ModelSetting
|
||||||
#########################################################
|
#########################################################
|
||||||
|
|
||||||
class Logic(object):
|
class Logic(object):
|
||||||
db_default = {
|
db_default = {
|
||||||
'db_version': '1',
|
'db_version': '1',
|
||||||
|
'youtube_dl_package': '0',
|
||||||
'ffmpeg_path': '' if platform.system() != 'Windows' else os.path.join(path_app_root, 'bin', 'Windows', 'ffmpeg.exe'),
|
'ffmpeg_path': '' if platform.system() != 'Windows' else os.path.join(path_app_root, 'bin', 'Windows', 'ffmpeg.exe'),
|
||||||
'temp_path': os.path.join(path_data, 'download_tmp'),
|
'temp_path': os.path.join(path_data, 'download_tmp'),
|
||||||
'save_path': os.path.join(path_data, 'download'),
|
'save_path': os.path.join(path_data, 'download'),
|
||||||
@@ -55,8 +57,9 @@ class Logic(object):
|
|||||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'glob2'], universal_newlines=True))
|
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'glob2'], universal_newlines=True))
|
||||||
|
|
||||||
# youtube-dl 업데이트
|
# youtube-dl 업데이트
|
||||||
logger.debug('youtube-dl upgrade')
|
youtube_dl = LogicNormal.get_youtube_dl_package(ModelSetting.get('youtube_dl_package'))
|
||||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--upgrade', 'youtube-dl'], universal_newlines=True))
|
logger.debug('%s upgrade' % youtube_dl)
|
||||||
|
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--upgrade', youtube_dl], universal_newlines=True))
|
||||||
|
|
||||||
# 편의를 위해 json 파일 생성
|
# 편의를 위해 json 파일 생성
|
||||||
from .plugin import plugin_info
|
from .plugin import plugin_info
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ from .my_youtube_dl import MyYoutubeDL, Status
|
|||||||
class LogicNormal(object):
|
class LogicNormal(object):
|
||||||
youtube_dl_list = []
|
youtube_dl_list = []
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_youtube_dl_package(index=None):
|
||||||
|
packages = ['youtube-dl', 'youtube-dlc']
|
||||||
|
if index is None:
|
||||||
|
return packages
|
||||||
|
else:
|
||||||
|
return packages[int(index)].replace('-', '_')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_youtube_dl_version():
|
def get_youtube_dl_version():
|
||||||
return MyYoutubeDL.get_version()
|
return MyYoutubeDL.get_version()
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ class MyYoutubeDL(object):
|
|||||||
_last_msg = ''
|
_last_msg = ''
|
||||||
|
|
||||||
def __init__(self, plugin, url, filename, temp_path, save_path=None, opts=None, dateafter=None, datebefore=None):
|
def __init__(self, plugin, url, filename, temp_path, save_path=None, opts=None, dateafter=None, datebefore=None):
|
||||||
from youtube_dl.utils import DateRange
|
# from youtube_dl.utils import DateRange
|
||||||
|
from .plugin import YOUTUBE_DL_PACKAGE
|
||||||
|
DateRange = __import__('%s.utils' % YOUTUBE_DL_PACKAGE, fromlist=['DateRange']).DateRange
|
||||||
|
|
||||||
if save_path is None:
|
if save_path is None:
|
||||||
save_path = temp_path
|
save_path = temp_path
|
||||||
@@ -99,7 +101,9 @@ class MyYoutubeDL(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
import youtube_dl
|
# import youtube_dl
|
||||||
|
from .plugin import YOUTUBE_DL_PACKAGE
|
||||||
|
youtube_dl = __import__('%s' % YOUTUBE_DL_PACKAGE)
|
||||||
import glob2
|
import glob2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -153,13 +157,17 @@ class MyYoutubeDL(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_version():
|
def get_version():
|
||||||
from youtube_dl.version import __version__
|
# from youtube_dl.version import __version__
|
||||||
|
from .plugin import YOUTUBE_DL_PACKAGE
|
||||||
|
__version__ = __import__('%s.version' % YOUTUBE_DL_PACKAGE, fromlist=['__version__']).__version__
|
||||||
|
|
||||||
return __version__
|
return __version__
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_info_dict(url, proxy=None):
|
def get_info_dict(url, proxy=None):
|
||||||
import youtube_dl
|
# import youtube_dl
|
||||||
|
from .plugin import YOUTUBE_DL_PACKAGE
|
||||||
|
youtube_dl = __import__('%s' % YOUTUBE_DL_PACKAGE)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package_name = __name__.split('.')[0]
|
|||||||
logger = get_logger(package_name)
|
logger = get_logger(package_name)
|
||||||
from .logic import Logic
|
from .logic import Logic
|
||||||
from .logic_normal import LogicNormal
|
from .logic_normal import LogicNormal
|
||||||
|
YOUTUBE_DL_PACKAGE = LogicNormal.get_youtube_dl_package(Logic.db_default['youtube_dl_package'])
|
||||||
from .model import ModelSetting
|
from .model import ModelSetting
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
@@ -43,7 +44,7 @@ menu = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin_info = {
|
plugin_info = {
|
||||||
'version': '1.7.0',
|
'version': '2.0.0',
|
||||||
'name': 'youtube-dl',
|
'name': 'youtube-dl',
|
||||||
'category_name': 'vod',
|
'category_name': 'vod',
|
||||||
'developer': 'joyfuI',
|
'developer': 'joyfuI',
|
||||||
@@ -54,6 +55,8 @@ plugin_info = {
|
|||||||
|
|
||||||
def plugin_load():
|
def plugin_load():
|
||||||
Logic.plugin_load()
|
Logic.plugin_load()
|
||||||
|
global YOUTUBE_DL_PACKAGE
|
||||||
|
YOUTUBE_DL_PACKAGE = LogicNormal.get_youtube_dl_package(ModelSetting.get('youtube_dl_package'))
|
||||||
|
|
||||||
def plugin_unload():
|
def plugin_unload():
|
||||||
Logic.plugin_unload()
|
Logic.plugin_unload()
|
||||||
@@ -73,6 +76,7 @@ def first_menu(sub):
|
|||||||
|
|
||||||
if sub == 'setting':
|
if sub == 'setting':
|
||||||
arg.update(ModelSetting.to_dict())
|
arg.update(ModelSetting.to_dict())
|
||||||
|
arg['package_list'] = LogicNormal.get_youtube_dl_package()
|
||||||
arg['youtube_dl_version'] = LogicNormal.get_youtube_dl_version()
|
arg['youtube_dl_version'] = LogicNormal.get_youtube_dl_version()
|
||||||
arg['DEFAULT_FILENAME'] = LogicNormal.get_default_filename()
|
arg['DEFAULT_FILENAME'] = LogicNormal.get_default_filename()
|
||||||
return render_template('%s_%s.html' % (package_name, sub), arg=arg)
|
return render_template('%s_%s.html' % (package_name, sub), arg=arg)
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
{{ macros.setting_input_text('url', 'URL', placeholder='http:// 주소', desc='유튜브, 네이버TV 등 동영상 주소') }}
|
{{ macros.setting_input_text('url', 'URL', placeholder='http:// 주소', desc='유튜브, 네이버TV 등 동영상 주소') }}
|
||||||
{{ macros.setting_input_text('filename', '파일명', value=arg['filename'], desc='템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고') }}
|
{{ macros.setting_input_text('filename', '파일명', value=arg['filename'], desc='템플릿 규칙은 https://github.com/blackjack4494/yt-dlc#output-template 참고') }}
|
||||||
{{ macros.setting_select('preset', '동영상 포맷 프리셋', arg['preset_list'], col='3') }}
|
{{ macros.setting_select('preset', '동영상 포맷 프리셋', arg['preset_list'], col='3') }}
|
||||||
{{ macros.setting_input_text('format', '동영상 포맷', desc=['포맷 지정은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection 참고', '빈칸으로 두면 최고 화질로 다운로드합니다.']) }}
|
{{ macros.setting_input_text('format', '동영상 포맷', desc=['포맷 지정은 https://github.com/blackjack4494/yt-dlc#format-selection 참고', '빈칸으로 두면 최고 화질로 다운로드합니다.']) }}
|
||||||
{{ setting_select2('postprocessor', '후처리', arg['postprocessor_list'], col='3', desc='다운로드 후 FFmpeg로 후처리합니다.') }}
|
{{ setting_select2('postprocessor', '후처리', arg['postprocessor_list'], col='3', desc='다운로드 후 FFmpeg로 후처리합니다.') }}
|
||||||
{{ macros.setting_button([['download_btn', '다운로드']]) }}
|
{{ macros.setting_button([['download_btn', '다운로드']]) }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{{ macros.setting_input_text('youtube_dl_version', 'youtube-dl 버전', value=arg['youtube_dl_version']) }}
|
|
||||||
<form id="setting">
|
<form id="setting">
|
||||||
|
{{ macros.setting_radio('youtube_dl_package', 'youtube-dl', arg['package_list'], value=arg['youtube_dl_package'], desc='사용할 youtube-dl 패키지를 선택합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
||||||
|
{{ macros.setting_input_text('youtube_dl_version', 'youtube-dl 버전', value=arg['youtube_dl_version'], disabled=True) }}
|
||||||
{{ macros.setting_input_text_and_buttons('ffmpeg_path', 'FFmpeg 경로', [['ffmpeg_version', '버전확인']], value=arg['ffmpeg_path'], placeholder='ffmpeg', desc='SJVA에 내장된 버전 말고 원하는 버전을 사용할 수 있습니다.') }}
|
{{ macros.setting_input_text_and_buttons('ffmpeg_path', 'FFmpeg 경로', [['ffmpeg_version', '버전확인']], value=arg['ffmpeg_path'], placeholder='ffmpeg', desc='SJVA에 내장된 버전 말고 원하는 버전을 사용할 수 있습니다.') }}
|
||||||
{{ macros.setting_input_text('temp_path', '임시 폴더', value=arg['temp_path'], desc='다운로드 파일이 임시로 저장될 폴더입니다.') }}
|
{{ macros.setting_input_text('temp_path', '임시 폴더', value=arg['temp_path'], desc='다운로드 파일이 임시로 저장될 폴더입니다.') }}
|
||||||
{{ macros.setting_input_text('save_path', '저장 폴더', value=arg['save_path'], desc='정상적으로 완료된 파일이 이동할 폴더입니다.') }}
|
{{ macros.setting_input_text('save_path', '저장 폴더', value=arg['save_path'], desc='정상적으로 완료된 파일이 이동할 폴더입니다.') }}
|
||||||
{{ macros.setting_input_text('default_filename', '기본 파일명', value=arg['default_filename'], placeholder=arg['DEFAULT_FILENAME'], desc='템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고') }}
|
{{ macros.setting_input_text('default_filename', '기본 파일명', value=arg['default_filename'], placeholder=arg['DEFAULT_FILENAME'], desc='템플릿 규칙은 https://github.com/blackjack4494/yt-dlc#output-template 참고') }}
|
||||||
{{ macros.setting_input_text('proxy', '프록시', value=arg['proxy'], desc=['HTTP/HTTPS/SOCKS를 지원합니다. 예) socks5://127.0.0.1:1080/', '빈칸으로 두면 프록시를 사용하지 않습니다.']) }}
|
{{ macros.setting_input_text('proxy', '프록시', value=arg['proxy'], desc=['HTTP/HTTPS/SOCKS를 지원합니다. 예) socks5://127.0.0.1:1080/', '빈칸으로 두면 프록시를 사용하지 않습니다.']) }}
|
||||||
{{ macros.setting_checkbox('activate_cors', 'CORS 허용', value=arg['activate_cors'], desc='API로의 크로스 도메인 요청을 허용합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
{{ macros.setting_checkbox('activate_cors', 'CORS 허용', value=arg['activate_cors'], desc='API로의 크로스 도메인 요청을 허용합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
||||||
{{ macros.setting_button([['global_setting_save_btn', '저장']]) }}
|
{{ macros.setting_button([['global_setting_save_btn', '저장']]) }}
|
||||||
@@ -19,8 +20,6 @@
|
|||||||
const package_name = '{{ arg["package_name"] }}';
|
const package_name = '{{ arg["package_name"] }}';
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#youtube_dl_version').prop('readonly', true);
|
|
||||||
|
|
||||||
// FFmpeg 버전확인
|
// FFmpeg 버전확인
|
||||||
$('#ffmpeg_version').click(function () {
|
$('#ffmpeg_version').click(function () {
|
||||||
let ffmpeg_path = $('#ffmpeg_path').val();
|
let ffmpeg_path = $('#ffmpeg_path').val();
|
||||||
|
|||||||
Reference in New Issue
Block a user