projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[iprima] Improve video id extraction (#26507) (closes #26494)
[youtube-dl]
/
youtube_dl
/
extractor
/
snotr.py
diff --git
a/youtube_dl/extractor/snotr.py
b/youtube_dl/extractor/snotr.py
index f89e81bf32035f689fa8adf520055729973ceb18..f773547483fbf7828118b7b3ff2e537e05b9628c 100644
(file)
--- a/
youtube_dl/extractor/snotr.py
+++ b/
youtube_dl/extractor/snotr.py
@@
-4,70
+4,70
@@
from __future__ import unicode_literals
import re
from .common import InfoExtractor
import re
from .common import InfoExtractor
-
from ..utils import (
from ..utils import (
-
+ parse_duration,
+ parse_filesize,
str_to_int,
str_to_int,
- parse_iso8601,
-
-
-
)
)
+
class SnotrIE(InfoExtractor):
_VALID_URL = r'http?://(?:www\.)?snotr\.com/video/(?P<id>\d+)/([\w]+)'
class SnotrIE(InfoExtractor):
_VALID_URL = r'http?://(?:www\.)?snotr\.com/video/(?P<id>\d+)/([\w]+)'
- _TESTS =
[
{
+ _TESTS =
[
{
'url': 'http://www.snotr.com/video/13708/Drone_flying_through_fireworks',
'info_dict': {
'id': '13708',
'url': 'http://www.snotr.com/video/13708/Drone_flying_through_fireworks',
'info_dict': {
'id': '13708',
- 'ext': '
flv
',
+ 'ext': '
mp4
',
'title': 'Drone flying through fireworks!',
'title': 'Drone flying through fireworks!',
- 'duration': 247,
- 'filesize':12320768
- }
- },
-
-
-
- {
-
+ 'duration': 248,
+ 'filesize_approx': 40700000,
+ 'description': 'A drone flying through Fourth of July Fireworks',
+ 'thumbnail': r're:^https?://.*\.jpg$',
+ },
+ 'expected_warnings': ['description'],
+ }, {
'url': 'http://www.snotr.com/video/530/David_Letteman_-_George_W_Bush_Top_10',
'info_dict': {
'id': '530',
'url': 'http://www.snotr.com/video/530/David_Letteman_-_George_W_Bush_Top_10',
'info_dict': {
'id': '530',
- 'ext': '
flv
',
+ 'ext': '
mp4
',
'title': 'David Letteman - George W. Bush Top 10',
'duration': 126,
'title': 'David Letteman - George W. Bush Top 10',
'duration': 126,
- 'filesize': 1048576
- }
- }]
-
+ 'filesize_approx': 8500000,
+ 'description': 'The top 10 George W. Bush moments, brought to you by David Letterman!',
+ 'thumbnail': r're:^https?://.*\.jpg$',
+ }
+ }]
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
- # TODO more code goes here, for example ...
webpage = self._download_webpage(url, video_id)
title = self._og_search_title(webpage)
description = self._og_search_description(webpage)
webpage = self._download_webpage(url, video_id)
title = self._og_search_title(webpage)
description = self._og_search_description(webpage)
+ info_dict = self._parse_html5_media_entries(
+ url, webpage, video_id, m3u8_entry_protocol='m3u8_native')[0]
- vi
deo_url = "http://cdn.videos.snotr.com/%s.flv" % video_id
-
-
view_count = str_to_int(self._html_search_regex(r'<p>\n<strong>Views:</strong>\n([\d,\.]+)</p>',webpage,'view count'
))
+ vi
ew_count = str_to_int(self._html_search_regex(
+ r'<p[^>]*>\s*<strong[^>]*>Views:</strong>\s*<span[^>]*>([\d,\.]+)',
+
webpage, 'view count', fatal=False
))
- duration = self._html_search_regex(r'<p>\n<strong>Length:</strong>\n(.*?)</p>',webpage,'duration')
- duration = str_to_int(duration[:1])*60 + str_to_int(duration[2:4])
+ duration = parse_duration(self._html_search_regex(
+ r'<p[^>]*>\s*<strong[^>]*>Length:</strong>\s*<span[^>]*>([\d:]+)',
+ webpage, 'duration', fatal=False))
- file_size = self._html_search_regex(r'<p>\n<strong>Filesize:</strong>\n(.*?)</p>',webpage,'filesize')
- file_size = str_to_int(re.match(r'\d+',file_size).group())*131072
+ filesize_approx = parse_filesize(self._html_search_regex(
+ r'<p[^>]*>\s*<strong[^>]*>Filesize:</strong>\s*<span[^>]*>([^<]+)',
+ webpage, 'filesize', fatal=False))
-
return
{
+
info_dict.update(
{
'id': video_id,
'id': video_id,
+ 'description': description,
'title': title,
'title': title,
- '
url':video_url
,
- '
view_count':view_count
,
- '
duration':duration
,
- 'filesize':file_size
+ '
view_count': view_count
,
+ '
duration': duration
,
+ '
filesize_approx': filesize_approx
,
+ })
- }
\ No newline at end of file
+ return info_dict