From 05ec6de55f563e0c21f230755ed9a3bb183001f6 Mon Sep 17 00:00:00 2001 From: Roy Zuo <26777013+royjor2016@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:42:32 +0200 Subject: [PATCH 1/2] add [[Category:Videos of %(yyyy)s|%(mm_dd)s]] --- video2commons/frontend/urlextract.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/video2commons/frontend/urlextract.py b/video2commons/frontend/urlextract.py index 9112a8c..283063a 100644 --- a/video2commons/frontend/urlextract.py +++ b/video2commons/frontend/urlextract.py @@ -50,6 +50,7 @@ {{LicenseReview}} [[Category:Uploaded with video2commons]] +[[Category:Videos of %(yyyy)s|%(mm_dd)s]] """ @@ -102,7 +103,9 @@ def do_extract_url(url): 'date': _date(url, ie_key, title, info), 'source': _source(url, ie_key, title, info), 'uploader': _uploader(url, ie_key, title, info), - 'license': _license(url, ie_key, title, info) + 'license': _license(url, ie_key, title, info), + 'yyyy': _date(url, ie_key, title, info)[1], + 'mm_dd': _date(url, ie_key, title, info)[2] } return { @@ -115,9 +118,15 @@ def do_extract_url(url): def _date(url, ie_key, title, info): date = (info.get('upload_date') or '').strip() + yyyy = '' + mm_dd = '' + if re.match(r'^[0-9]{8}$', date): + yyyy = date[0:4] + mm_dd = f"{date[4:6]}-{date[6:8]}" date = '%s-%s-%s' % (date[0:4], date[4:6], date[6:8]) - return date + + return date, yyyy, mm_dd def _source(url, ie_key, title, info): From 3f59c542af8fa4a4461a7cd3d2884ca0707e79de Mon Sep 17 00:00:00 2001 From: Roy Zuo <26777013+royjor2016@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:51:16 +0200 Subject: [PATCH 2/2] mmdd --- video2commons/frontend/urlextract.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/video2commons/frontend/urlextract.py b/video2commons/frontend/urlextract.py index 283063a..357eee9 100644 --- a/video2commons/frontend/urlextract.py +++ b/video2commons/frontend/urlextract.py @@ -50,7 +50,7 @@ {{LicenseReview}} [[Category:Uploaded with video2commons]] -[[Category:Videos of %(yyyy)s|%(mm_dd)s]] +[[Category:Videos of %(yyyy)s|%(mmdd)s]] """ @@ -105,7 +105,7 @@ def do_extract_url(url): 'uploader': _uploader(url, ie_key, title, info), 'license': _license(url, ie_key, title, info), 'yyyy': _date(url, ie_key, title, info)[1], - 'mm_dd': _date(url, ie_key, title, info)[2] + 'mmdd': _date(url, ie_key, title, info)[2] } return { @@ -119,14 +119,14 @@ def do_extract_url(url): def _date(url, ie_key, title, info): date = (info.get('upload_date') or '').strip() yyyy = '' - mm_dd = '' + mmdd = '' if re.match(r'^[0-9]{8}$', date): yyyy = date[0:4] - mm_dd = f"{date[4:6]}-{date[6:8]}" + mmdd = date[4:8] date = '%s-%s-%s' % (date[0:4], date[4:6], date[6:8]) - return date, yyyy, mm_dd + return date, yyyy, mmdd def _source(url, ie_key, title, info):