1 from __future__ import unicode_literals
5 from .common import InfoExtractor
16 class ViewLiftBaseIE(InfoExtractor):
17 _DOMAINS_REGEX = r'(?:snagfilms|snagxtreme|funnyforfree|kiddovid|winnersview|monumentalsportsnetwork|vayafilm)\.com|kesari\.tv'
20 class ViewLiftEmbedIE(ViewLiftBaseIE):
21 _VALID_URL = r'https?://(?:(?:www|embed)\.)?(?:%s)/embed/player\?.*\bfilmId=(?P<id>[\da-f-]{36})' % ViewLiftBaseIE._DOMAINS_REGEX
23 'url': 'http://embed.snagfilms.com/embed/player?filmId=74849a00-85a9-11e1-9660-123139220831&w=500',
24 'md5': '2924e9215c6eff7a55ed35b72276bd93',
26 'id': '74849a00-85a9-11e1-9660-123139220831',
28 'title': '#whilewewatch',
31 # invalid labels, 360p is better that 480p
32 'url': 'http://www.snagfilms.com/embed/player?filmId=17ca0950-a74a-11e0-a92a-0026bb61d036',
33 'md5': '882fca19b9eb27ef865efeeaed376a48',
35 'id': '17ca0950-a74a-11e0-a92a-0026bb61d036',
37 'title': 'Life in Limbo',
40 'url': 'http://www.snagfilms.com/embed/player?filmId=0000014c-de2f-d5d6-abcf-ffef58af0017',
41 'only_matching': True,
45 def _extract_url(webpage):
47 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:embed\.)?(?:%s)/embed/player.+?)\1' % ViewLiftBaseIE._DOMAINS_REGEX,
50 return mobj.group('url')
52 def _real_extract(self, url):
53 video_id = self._match_id(url)
55 webpage = self._download_webpage(url, video_id)
57 if '>This film is not playable in your area.<' in webpage:
59 'Film %s is not playable in your area.' % video_id, expected=True)
63 for source in self._parse_json(js_to_json(self._search_regex(
64 r'(?s)sources:\s*(\[.+?\]),', webpage, 'json')), video_id):
65 file_ = source.get('file')
68 type_ = source.get('type')
69 ext = determine_ext(file_)
70 format_id = source.get('label') or ext
71 if all(v in ('m3u8', 'hls') for v in (type_, ext)):
72 formats.extend(self._extract_m3u8_formats(
73 file_, video_id, 'mp4', m3u8_id='hls'))
75 bitrate = int_or_none(self._search_regex(
76 [r'(\d+)kbps', r'_\d{1,2}x\d{1,2}_(\d{3,})\.%s' % ext],
77 file_, 'bitrate', default=None))
78 if not has_bitrate and bitrate:
80 height = int_or_none(self._search_regex(
81 r'^(\d+)[pP]$', format_id, 'height', default=None))
84 'format_id': 'http-%s%s' % (format_id, ('-%dk' % bitrate if bitrate else '')),
88 field_preference = None if has_bitrate else ('height', 'tbr', 'format_id')
89 self._sort_formats(formats, field_preference)
91 title = self._search_regex(
92 [r"title\s*:\s*'([^']+)'", r'<title>([^<]+)</title>'],
102 class ViewLiftIE(ViewLiftBaseIE):
103 _VALID_URL = r'https?://(?:www\.)?(?P<domain>%s)/(?:films/title|show|(?:news/)?videos?)/(?P<id>[^?#]+)' % ViewLiftBaseIE._DOMAINS_REGEX
105 'url': 'http://www.snagfilms.com/films/title/lost_for_life',
106 'md5': '19844f897b35af219773fd63bdec2942',
108 'id': '0000014c-de2f-d5d6-abcf-ffef58af0017',
109 'display_id': 'lost_for_life',
111 'title': 'Lost for Life',
112 'description': 'md5:fbdacc8bb6b455e464aaf98bc02e1c82',
113 'thumbnail': r're:^https?://.*\.jpg',
115 'categories': ['Documentary', 'Crime', 'Award Winning', 'Festivals']
118 'url': 'http://www.snagfilms.com/show/the_world_cut_project/india',
119 'md5': 'e6292e5b837642bbda82d7f8bf3fbdfd',
121 'id': '00000145-d75c-d96e-a9c7-ff5c67b20000',
122 'display_id': 'the_world_cut_project/india',
125 'description': 'md5:5c168c5a8f4719c146aad2e0dfac6f5f',
126 'thumbnail': r're:^https?://.*\.jpg',
128 'categories': ['Documentary', 'Sports', 'Politics']
131 # Film is not playable in your area.
132 'url': 'http://www.snagfilms.com/films/title/inside_mecca',
133 'only_matching': True,
135 # Film is not available.
136 'url': 'http://www.snagfilms.com/show/augie_alone/flirting',
137 'only_matching': True,
139 'url': 'http://www.winnersview.com/videos/the-good-son',
140 'only_matching': True,
142 'url': 'http://www.kesari.tv/news/video/1461919076414',
143 'only_matching': True,
145 # Was once Kaltura embed
146 'url': 'https://www.monumentalsportsnetwork.com/videos/john-carlson-postgame-2-25-15',
147 'only_matching': True,
150 def _real_extract(self, url):
151 domain, display_id = re.match(self._VALID_URL, url).groups()
153 webpage = self._download_webpage(url, display_id)
155 if ">Sorry, the Film you're looking for is not available.<" in webpage:
156 raise ExtractorError(
157 'Film %s is not available.' % display_id, expected=True)
159 film_id = self._search_regex(r'filmId=([\da-f-]{36})"', webpage, 'film id')
161 snag = self._parse_json(
163 r'Snag\.page\.data\s*=\s*(\[.+?\]);', webpage, 'snag'),
167 if item.get('data', {}).get('film', {}).get('id') == film_id:
168 data = item['data']['film']
169 title = data['title']
170 description = clean_html(data.get('synopsis'))
171 thumbnail = data.get('image')
172 duration = int_or_none(data.get('duration') or data.get('runtime'))
174 category['title'] for category in data.get('categories', [])
175 if category.get('title')]
178 title = self._search_regex(
179 r'itemprop="title">([^<]+)<', webpage, 'title')
180 description = self._html_search_regex(
181 r'(?s)<div itemprop="description" class="film-synopsis-inner ">(.+?)</div>',
182 webpage, 'description', default=None) or self._og_search_description(webpage)
183 thumbnail = self._og_search_thumbnail(webpage)
184 duration = parse_duration(self._search_regex(
185 r'<span itemprop="duration" class="film-duration strong">([^<]+)<',
186 webpage, 'duration', fatal=False))
187 categories = re.findall(r'<a href="/movies/[^"]+">([^<]+)</a>', webpage)
190 '_type': 'url_transparent',
191 'url': 'http://%s/embed/player?filmId=%s' % (domain, film_id),
193 'display_id': display_id,
195 'description': description,
196 'thumbnail': thumbnail,
197 'duration': duration,
198 'categories': categories,
199 'ie_key': 'ViewLiftEmbed',