1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-11 05:23:22 +08:00

[Vidbit] Extract base URL from

This commit is contained in:
TRox1972 2016-06-18 18:22:32 +02:00
parent e09c9aabb0
commit e2568ca666

View File

@ -1,8 +1,10 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor import re
from .common import InfoExtractor
from ..utils import url_basename
class VidbitIE(InfoExtractor): class VidbitIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?vidbit\.co/watch\?v=(?P<id>[\w-]+)' _VALID_URL = r'https?://(?:www\.)?vidbit\.co/watch\?v=(?P<id>[\w-]+)'
@ -13,20 +15,20 @@ class VidbitIE(InfoExtractor):
'id': 'MrM7LeaMJq', 'id': 'MrM7LeaMJq',
'ext': 'mp4', 'ext': 'mp4',
'title': 'RoboCop (1987) - Dick You\'re Fired', 'title': 'RoboCop (1987) - Dick You\'re Fired',
'thumbnail': 'http://vidbit.co/thumbnails/MrM7LeaMJq.jpg', 'thumbnail': 'http://www.vidbit.co/thumbnails/MrM7LeaMJq.jpg',
} }
} }
_BASE_URL = 'http://vidbit.co/%s'
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
_BASE_URL = 'http://' + url.split('/')[2] + '/'
return { return {
'id': video_id, 'id': video_id,
'title': self._html_search_regex(r'<h1>(.+)</h1>', webpage, 'title'), 'title': self._html_search_regex(r'<h1>(.+)</h1>', webpage, 'title'),
'url': self._BASE_URL % self._html_search_regex(r'file:\s*(["\'])((?:(?!\1).)+)\1', webpage, 'video URL', group=2), 'url': _BASE_URL + self._html_search_regex(r'file:\s*(["\'])((?:(?!\1).)+)\1', webpage, 'video URL', group=2),
'thumbnail': self._BASE_URL % self._html_search_regex(r'image:\s*(["\'])((?:(?!\1).)+)\1', webpage, 'thumbnail', None, group=2), 'thumbnail': _BASE_URL + self._html_search_regex(r'image:\s*(["\'])((?:(?!\1).)+)\1', webpage, 'thumbnail', None, group=2),
'description': self._html_search_regex(r'description:(["\'])((?:(?!\1).)+)\1', webpage, 'description', None, group=2), 'description': self._html_search_regex(r'description:(["\'])((?:(?!\1).)+)\1', webpage, 'description', None, group=2),
} }