Skip to content

Commit 56be348

Browse files
authored
Merge pull request #121 from TotallyNotRobots/gonzobot+fix-youtube-timeparse
Fix youtube.py timeparsing
2 parents 8b8353c + aa5b9da commit 56be348

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Refactor tests to remove dependency on mock library
1212
### Fixed
1313
- Fix matching exception in horoscope test
14+
- Fix youtube.py ISO time parse
1415

1516
## [1.3.0] 2020-03-17
1617
### Added

plugins/youtube.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import re
2-
import time
32

43
import isodate
54
import requests
@@ -72,9 +71,9 @@ def get_video_description(video_id):
7271

7372
uploader = snippet['channelTitle']
7473

75-
upload_time = time.strptime(snippet['publishedAt'], "%Y-%m-%dT%H:%M:%S.000Z")
74+
upload_time = isodate.parse_datetime(snippet['publishedAt'])
7675
out += ' - \x02{}\x02 on \x02{}\x02'.format(uploader,
77-
time.strftime("%Y.%m.%d", upload_time))
76+
upload_time.strftime("%Y.%m.%d"))
7877

7978
if 'contentRating' in content_details:
8079
out += ' - \x034NSFW\x02'

tests/plugin_tests/test_youtube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def mock_api_keys():
3333
'etag': '"p4VTdlkQv3HQeTEaXgvLePAydmU/8GTj_EHYgQmPYCDpJbQ4NM6r5B8"',
3434
'id': 'phL7P6gtZRM',
3535
'snippet': {
36-
'publishedAt': '2019-10-10T15:00:09.000Z',
36+
'publishedAt': '2019-10-10T15:00:09Z',
3737
'channelId': 'UCRUULstZRWS1lDvJBzHnkXA',
3838
'title': 'some title',
3939
'description': 'a description',

0 commit comments

Comments
 (0)