mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-11 02:57:20 +08:00
Merge branch 'master' of https://github.com/aviperes/youtube-dl
This commit is contained in:
commit
10ae3f24e3
@ -28,7 +28,12 @@ from ..utils import (
|
|||||||
|
|
||||||
|
|
||||||
class SoundcloudEmbedIE(InfoExtractor):
|
class SoundcloudEmbedIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:w|player|p)\.soundcloud\.com/player/?.*?url=(?P<id>.*)'
|
_VALID_URL = r'https?://(?:w|player|p)\.soundcloud\.com/player/?.*?\burl=(?P<id>.+)'
|
||||||
|
_TEST = {
|
||||||
|
# from https://www.soundi.fi/uutiset/ennakkokuuntelussa-timo-kaukolammen-station-to-station-to-station-julkaisua-juhlitaan-tanaan-g-livelabissa/
|
||||||
|
'url': 'https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F922213810&show_artwork=true&maxwidth=640&maxheight=960&dnt=1&secret_token=s-ziYey',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_urls(webpage):
|
def _extract_urls(webpage):
|
||||||
@ -37,8 +42,13 @@ class SoundcloudEmbedIE(InfoExtractor):
|
|||||||
webpage)]
|
webpage)]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
return self.url_result(compat_urlparse.parse_qs(
|
query = compat_urlparse.parse_qs(
|
||||||
compat_urlparse.urlparse(url).query)['url'][0])
|
compat_urlparse.urlparse(url).query)
|
||||||
|
api_url = query['url'][0]
|
||||||
|
secret_token = query.get('secret_token')
|
||||||
|
if secret_token:
|
||||||
|
api_url = update_url_query(api_url, {'secret_token': secret_token[0]})
|
||||||
|
return self.url_result(api_url)
|
||||||
|
|
||||||
|
|
||||||
class SoundcloudIE(InfoExtractor):
|
class SoundcloudIE(InfoExtractor):
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import functools
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
@ -11,6 +12,7 @@ from ..utils import (
|
|||||||
ExtractorError,
|
ExtractorError,
|
||||||
get_element_by_class,
|
get_element_by_class,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
OnDemandPagedList,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
@ -478,14 +480,23 @@ class VKIE(VKBaseIE):
|
|||||||
class VKUserVideosIE(VKBaseIE):
|
class VKUserVideosIE(VKBaseIE):
|
||||||
IE_NAME = 'vk:uservideos'
|
IE_NAME = 'vk:uservideos'
|
||||||
IE_DESC = "VK - User's Videos"
|
IE_DESC = "VK - User's Videos"
|
||||||
_VALID_URL = r'https?://(?:(?:m|new)\.)?vk\.com/videos(?P<id>-?[0-9]+)(?!\?.*\bz=video)(?:[/?#&]|$)'
|
_VALID_URL = r'https?://(?:(?:m|new)\.)?vk\.com/videos(?P<id>-?[0-9]+)(?!\?.*\bz=video)(?:[/?#&](?:.*?\bsection=(?P<section>\w+))?|$)'
|
||||||
_TEMPLATE_URL = 'https://vk.com/videos'
|
_TEMPLATE_URL = 'https://vk.com/videos'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://vk.com/videos205387401',
|
'url': 'https://vk.com/videos-767561',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '205387401',
|
'id': '-767561_all',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 4,
|
'playlist_mincount': 1150,
|
||||||
|
}, {
|
||||||
|
'url': 'https://vk.com/videos-767561?section=uploaded',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '-767561_uploaded',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 425,
|
||||||
|
}, {
|
||||||
|
'url': 'http://vk.com/videos205387401',
|
||||||
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://vk.com/videos-77521',
|
'url': 'http://vk.com/videos-77521',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -499,25 +510,33 @@ class VKUserVideosIE(VKBaseIE):
|
|||||||
'url': 'http://new.vk.com/videos205387401',
|
'url': 'http://new.vk.com/videos205387401',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
_VIDEO = collections.namedtuple(
|
_PAGE_SIZE = 1000
|
||||||
'Video', ['owner_id', 'id', 'thumb', 'title', 'flags', 'duration', 'hash', 'moder_acts', 'owner', 'date', 'views', 'platform', 'blocked', 'music_video_meta'])
|
_VIDEO = collections.namedtuple('Video', ['owner_id', 'id'])
|
||||||
|
|
||||||
def _real_extract(self, url):
|
|
||||||
page_id = self._match_id(url)
|
|
||||||
|
|
||||||
|
def _fetch_page(self, page_id, section, page):
|
||||||
l = self._download_payload('al_video', page_id, {
|
l = self._download_payload('al_video', page_id, {
|
||||||
'act': 'load_videos_silent',
|
'act': 'load_videos_silent',
|
||||||
|
'offset': page * self._PAGE_SIZE,
|
||||||
'oid': page_id,
|
'oid': page_id,
|
||||||
})[0]['']['list']
|
'section': section,
|
||||||
|
})[0][section]['list']
|
||||||
|
|
||||||
entries = []
|
|
||||||
for video in l:
|
for video in l:
|
||||||
v = self._VIDEO._make(video)
|
v = self._VIDEO._make(video[:2])
|
||||||
video_id = '%d_%d' % (v.owner_id, v.id)
|
video_id = '%d_%d' % (v.owner_id, v.id)
|
||||||
entries.append(self.url_result(
|
yield self.url_result(
|
||||||
'http://vk.com/video' + video_id, 'VK', video_id=video_id))
|
'http://vk.com/video' + video_id, VKIE.ie_key(), video_id)
|
||||||
|
|
||||||
return self.playlist_result(entries, page_id)
|
def _real_extract(self, url):
|
||||||
|
page_id, section = re.match(self._VALID_URL, url).groups()
|
||||||
|
if not section:
|
||||||
|
section = 'all'
|
||||||
|
|
||||||
|
entries = OnDemandPagedList(
|
||||||
|
functools.partial(self._fetch_page, page_id, section),
|
||||||
|
self._PAGE_SIZE)
|
||||||
|
|
||||||
|
return self.playlist_result(entries, '%s_%s' % (page_id, section))
|
||||||
|
|
||||||
|
|
||||||
class VKWallPostIE(VKBaseIE):
|
class VKWallPostIE(VKBaseIE):
|
||||||
@ -581,8 +600,7 @@ class VKWallPostIE(VKBaseIE):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
_BASE64_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/='
|
_BASE64_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/='
|
||||||
_AUDIO = collections.namedtuple(
|
_AUDIO = collections.namedtuple('Audio', ['id', 'owner_id', 'url', 'title', 'performer', 'duration', 'album_id', 'unk', 'author_link', 'lyrics', 'flags', 'context', 'extra', 'hashes', 'cover_url', 'ads'])
|
||||||
'Audio', ['id', 'owner_id', 'url', 'title', 'performer', 'duration', 'album_id', 'unk', 'author_link', 'lyrics', 'flags', 'context', 'extra', 'hashes', 'cover_url', 'ads', 'subtitle', 'main_artists', 'feat_artists', 'album', 'track_code', 'restriction', 'album_part', 'new_stats', 'access_key'])
|
|
||||||
|
|
||||||
def _decode(self, enc):
|
def _decode(self, enc):
|
||||||
dec = ''
|
dec = ''
|
||||||
@ -630,7 +648,7 @@ class VKWallPostIE(VKBaseIE):
|
|||||||
|
|
||||||
for audio in re.findall(r'data-audio="([^"]+)', webpage):
|
for audio in re.findall(r'data-audio="([^"]+)', webpage):
|
||||||
audio = self._parse_json(unescapeHTML(audio), post_id)
|
audio = self._parse_json(unescapeHTML(audio), post_id)
|
||||||
a = self._AUDIO._make(audio)
|
a = self._AUDIO._make(audio[:16])
|
||||||
if not a.url:
|
if not a.url:
|
||||||
continue
|
continue
|
||||||
title = unescapeHTML(a.title)
|
title = unescapeHTML(a.title)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user