From 62c84f0e0ef966b9ef803a5114b05770599188d5 Mon Sep 17 00:00:00 2001 From: martmists Date: Tue, 30 May 2017 19:38:14 +0000 Subject: [PATCH 1/2] Add more information from the .sidestats bar --- youtube_dl/extractor/newgrounds.py | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/newgrounds.py b/youtube_dl/extractor/newgrounds.py index 9bea610c8..feb80b147 100644 --- a/youtube_dl/extractor/newgrounds.py +++ b/youtube_dl/extractor/newgrounds.py @@ -13,6 +13,8 @@ class NewgroundsIE(InfoExtractor): 'ext': 'mp3', 'title': 'B7 - BusMode', 'uploader': 'Burn7', + 'upload_date': '20130911', + 'duration': 143 } }, { 'url': 'https://www.newgrounds.com/portal/view/673111', @@ -37,10 +39,35 @@ class NewgroundsIE(InfoExtractor): music_url = self._parse_json(self._search_regex( r'"url":("[^"]+"),', webpage, ''), media_id) - - return { + + match = re.search( + (r'"sidestats">\s*
Uploaded
\s*
(.+?)
\s' + r'([a-z0-9 ]+)
\s
Score'), webpage) + + ret_data = { 'id': media_id, 'title': title, 'url': music_url, 'uploader': uploader, } + + if match is not None: + uploaded_at, length = match.groups() + + date = datetime.datetime.strptime(uploaded_at, "%b %m, %Y | %I:%M %p %Z") + + ret_data["upload_date"] = date.strftime("%Y%m%d") + + fmt = "%H hrs %M min %S sec" + + duration = None + + while duration is None: + try: + duration = datetime.datetime.strptime(length, fmt) + except ValueError: + fmt = fmt[7:] + + ret_data["duration"] = duration + + return ret_data From 87c23f8e0297901e68cb1665bf8a2cf2b3e877cb Mon Sep 17 00:00:00 2001 From: martmists Date: Tue, 30 May 2017 19:40:52 +0000 Subject: [PATCH 2/2] Update newgrounds.py --- youtube_dl/extractor/newgrounds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/newgrounds.py b/youtube_dl/extractor/newgrounds.py index feb80b147..2ecaf9cf7 100644 --- a/youtube_dl/extractor/newgrounds.py +++ b/youtube_dl/extractor/newgrounds.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals from .common import InfoExtractor - +import re class NewgroundsIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?newgrounds\.com/(?:audio/listen|portal/view)/(?P[0-9]+)'