Skip to content

Commit

Permalink
[newgrounds] Fix metadata extraction (closes ytdl-org#15531)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Feb 9, 2018
1 parent 5828489 commit 9e167e1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions youtube_dl/extractor/newgrounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,21 @@ def _real_extract(self, url):
self._check_formats(formats, media_id)
self._sort_formats(formats)

uploader = self._search_regex(
r'(?:Author|Writer)\s*<a[^>]+>([^<]+)', webpage, 'uploader',
uploader = self._html_search_regex(
(r'(?s)<h4[^>]*>(.+?)</h4>.*?<em>\s*Author\s*</em>',
r'(?:Author|Writer)\s*<a[^>]+>([^<]+)'), webpage, 'uploader',
fatal=False)

timestamp = unified_timestamp(self._search_regex(
r'<dt>Uploaded</dt>\s*<dd>([^<]+)', webpage, 'timestamp',
timestamp = unified_timestamp(self._html_search_regex(
(r'<dt>\s*Uploaded\s*</dt>\s*<dd>([^<]+</dd>\s*<dd>[^<]+)',
r'<dt>\s*Uploaded\s*</dt>\s*<dd>([^<]+)'), webpage, 'timestamp',
default=None))
duration = parse_duration(self._search_regex(
r'<dd>Song\s*</dd><dd>.+?</dd><dd>([^<]+)', webpage, 'duration',
default=None))
r'(?s)<dd>\s*Song\s*</dd>\s*<dd>.+?</dd>\s*<dd>([^<]+)', webpage,
'duration', default=None))

filesize_approx = parse_filesize(self._html_search_regex(
r'<dd>Song\s*</dd><dd>(.+?)</dd>', webpage, 'filesize',
r'(?s)<dd>\s*Song\s*</dd>\s*<dd>(.+?)</dd>', webpage, 'filesize',
default=None))
if len(formats) == 1:
formats[0]['filesize_approx'] = filesize_approx
Expand Down

0 comments on commit 9e167e1

Please sign in to comment.