mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 03:33:02 +00:00
[varzesh3] Simplify
This commit is contained in:
parent
69c3af567d
commit
55cde6ef3c
1 changed files with 20 additions and 23 deletions
|
@ -1,48 +1,45 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
|
||||||
ExtractorError,
|
|
||||||
)
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class Varzesh3IE(InfoExtractor):
|
class Varzesh3IE(InfoExtractor):
|
||||||
_VALID_URL = r'(?P<url>(https?://(?:www\.)?video\.varzesh3\.com)/(?P<id>.+))'
|
_VALID_URL = r'https?://(?:www\.)?video\.varzesh3\.com/(?:[^/]+/)+(?P<id>[^/]+)/?'
|
||||||
_TEST ={
|
_TEST = {
|
||||||
'url': 'http://video.varzesh3.com/germany/bundesliga/5-%D9%88%D8%A7%DA%A9%D9%86%D8%B4-%D8%A8%D8%B1%D8%AA%D8%B1-%D8%AF%D8%B1%D9%88%D8%A7%D8%B2%D9%87%E2%80%8C%D8%A8%D8%A7%D9%86%D8%A7%D9%86%D8%9B%D9%87%D9%81%D8%AA%D9%87-26-%D8%A8%D9%88%D9%86%D8%AF%D8%B3/',
|
'url': 'http://video.varzesh3.com/germany/bundesliga/5-%D9%88%D8%A7%DA%A9%D9%86%D8%B4-%D8%A8%D8%B1%D8%AA%D8%B1-%D8%AF%D8%B1%D9%88%D8%A7%D8%B2%D9%87%E2%80%8C%D8%A8%D8%A7%D9%86%D8%A7%D9%86%D8%9B%D9%87%D9%81%D8%AA%D9%87-26-%D8%A8%D9%88%D9%86%D8%AF%D8%B3/',
|
||||||
'md5': '2a933874cb7dce4366075281eb49e855',
|
'md5': '2a933874cb7dce4366075281eb49e855',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'url': 'http://dl1.video.varzesh3.com/video/clip94/1/video/namayeshi/saves_week26.mp4',
|
|
||||||
'id': '76337',
|
'id': '76337',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '۵ واکنش برتر دروازهبانان؛هفته ۲۶ بوندسلیگا',
|
'title': '۵ واکنش برتر دروازهبانان؛هفته ۲۶ بوندسلیگا',
|
||||||
'thumbnail': 'http://video.varzesh3.com/wp-content/uploads/230315_saves_week26.jpg',
|
|
||||||
'description': 'فصل ۲۰۱۵-۲۰۱۴',
|
'description': 'فصل ۲۰۱۵-۲۰۱۴',
|
||||||
|
'thumbnail': 're:^https?://.*\.jpg$',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
|
||||||
|
|
||||||
if not 'shortlink' in webpage:
|
webpage = self._download_webpage(url, display_id)
|
||||||
raise ExtractorError('URL has no videos or there is a problem.')
|
|
||||||
|
|
||||||
title = self._html_search_regex(r'meta[^>]+property="og:title"[^>]+content="([^"]+)"', webpage, 'title')
|
video_url = self._search_regex(
|
||||||
video_link = self._html_search_regex(r'source[^>]+src="([^"]+)"', webpage, 'video_link')
|
r'<source[^>]+src="([^"]+)"', webpage, 'video url')
|
||||||
vid_id = self._html_search_regex(r"link[^>]+rel='canonical'[^>]+href='\/\?p=([^']+)'\/>", webpage, 'vid_id')
|
|
||||||
try:
|
title = self._og_search_title(webpage)
|
||||||
description = self._html_search_regex(r'<div class="matn">(.*?)</div>', webpage, 'description', flags=re.DOTALL)
|
description = self._html_search_regex(
|
||||||
except:
|
r'(?s)<div class="matn">(.+?)</div>',
|
||||||
description = title
|
webpage, 'description', fatal=False)
|
||||||
thumbnail = self._html_search_regex(r'link[^>]+rel="image_src"[^>]+href="([^"]+)"', webpage, 'thumbnail')
|
thumbnail = self._og_search_thumbnail(webpage)
|
||||||
|
|
||||||
|
video_id = self._search_regex(
|
||||||
|
r"<link[^>]+rel='(?:canonical|shortlink)'[^>]+href='/\?p=([^']+)'",
|
||||||
|
webpage, display_id, default=display_id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'url': video_link,
|
'url': video_url,
|
||||||
'id': vid_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'ext': video_link.split(".")[-1],
|
|
||||||
'description': description,
|
'description': description,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue