pass referer to video download
This commit is contained in:
parent
5d6e753b05
commit
4cf28434eb
4 changed files with 13 additions and 4 deletions
|
@ -57,6 +57,8 @@ def get_info(url):
|
||||||
info[-1]['tags'] = []
|
info[-1]['tags'] = []
|
||||||
if 'upload_date' in i and i['upload_date']:
|
if 'upload_date' in i and i['upload_date']:
|
||||||
info[-1]['date'] = '-'.join([i['upload_date'][:4], i['upload_date'][4:6], i['upload_date'][6:]])
|
info[-1]['date'] = '-'.join([i['upload_date'][:4], i['upload_date'][4:6], i['upload_date'][6:]])
|
||||||
|
if 'referer' not in info[-1]:
|
||||||
|
info[-1]['referer'] = url
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def add_subtitles(item, media, tmp):
|
def add_subtitles(item, media, tmp):
|
||||||
|
@ -84,7 +86,7 @@ def add_subtitles(item, media, tmp):
|
||||||
sub.selected = True
|
sub.selected = True
|
||||||
sub.save()
|
sub.save()
|
||||||
|
|
||||||
def download(item_id, url):
|
def download(item_id, url, referer=None):
|
||||||
item = Item.objects.get(public_id=item_id)
|
item = Item.objects.get(public_id=item_id)
|
||||||
info = get_info(url)
|
info = get_info(url)
|
||||||
if not len(info):
|
if not len(info):
|
||||||
|
@ -96,6 +98,11 @@ def download(item_id, url):
|
||||||
tmp = tmp.decode('utf-8')
|
tmp = tmp.decode('utf-8')
|
||||||
os.chdir(tmp)
|
os.chdir(tmp)
|
||||||
cmd = ['youtube-dl', '-q', media['url']]
|
cmd = ['youtube-dl', '-q', media['url']]
|
||||||
|
if referer:
|
||||||
|
cmd += ['--referer', referer]
|
||||||
|
elif 'referer' in media:
|
||||||
|
cmd += ['--referer', media['referer']]
|
||||||
|
|
||||||
if settings.CONFIG['video'].get('reuseUload', False):
|
if settings.CONFIG['video'].get('reuseUload', False):
|
||||||
max_resolution = max(settings.CONFIG['video']['resolutions'])
|
max_resolution = max(settings.CONFIG['video']['resolutions'])
|
||||||
format = settings.CONFIG['video']['formats'][0]
|
format = settings.CONFIG['video']['formats'][0]
|
||||||
|
|
|
@ -200,8 +200,8 @@ def update_stream(id):
|
||||||
c.save()
|
c.save()
|
||||||
|
|
||||||
@task(queue="encoding")
|
@task(queue="encoding")
|
||||||
def download_media(item_id, url):
|
def download_media(item_id, url, referer=None):
|
||||||
return external.download(item_id, url)
|
return external.download(item_id, url, referer)
|
||||||
|
|
||||||
@task(queue='default')
|
@task(queue='default')
|
||||||
def move_media(data, user):
|
def move_media(data, user):
|
||||||
|
|
|
@ -745,6 +745,7 @@ def addMediaUrl(request, data):
|
||||||
|
|
||||||
takes {
|
takes {
|
||||||
url: string, // url
|
url: string, // url
|
||||||
|
referer: string // optional referer url
|
||||||
item: string // item
|
item: string // item
|
||||||
}
|
}
|
||||||
returns {
|
returns {
|
||||||
|
@ -757,7 +758,7 @@ def addMediaUrl(request, data):
|
||||||
response = json_response()
|
response = json_response()
|
||||||
i = Item.objects.get(public_id=data['item'])
|
i = Item.objects.get(public_id=data['item'])
|
||||||
Task.start(i, request.user)
|
Task.start(i, request.user)
|
||||||
t = tasks.download_media.delay(data['item'], data['url'])
|
t = tasks.download_media.delay(data['item'], data['url'], data.get('referer'))
|
||||||
response['data']['taskId'] = t.task_id
|
response['data']['taskId'] = t.task_id
|
||||||
add_changelog(request, data, data['item'])
|
add_changelog(request, data, data['item'])
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
|
@ -132,6 +132,7 @@ pandora.ui.importMediaDialog = function(options) {
|
||||||
pandora.api.edit(edit, function(result) {
|
pandora.api.edit(edit, function(result) {
|
||||||
pandora.api.addMediaUrl({
|
pandora.api.addMediaUrl({
|
||||||
url: info.url,
|
url: info.url,
|
||||||
|
referer: info.referer,
|
||||||
item: edit.id
|
item: edit.id
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
if (result.data.taskId) {
|
if (result.data.taskId) {
|
||||||
|
|
Loading…
Reference in a new issue