mps-youtube / yewtube

yewtube, forked from mps-youtube , is a Terminal based YouTube player and downloader. No Youtube API key required.
GNU General Public License v3.0
8.07k stars 645 forks source link

ValueError: Time data '...00:48Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ' after quiting playlist #1080

Closed timostrating closed 1 year ago

timostrating commented 4 years ago

ValueError: time data '2014-09-11T04:00:48Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

When I listen to some music from a public playlist and I quit out of the playlist by pressing Ctrl + C once. After doing this I sometimes get this error message. I can not reproduce the bug all the time.

Issue / Suggestion

Somehow on this line there can be a : instead of a . I have no idea what the impact would be if this small change would be made so that is why i made this issue: https://github.com/mps-youtube/mps-youtube/blob/develop/mps_youtube/util.py#L346

Traceback (most recent call last): File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/main.py", line 65, in matchfunction func(*matches) File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/commands/search.py", line 386, in pl_search g.content = content.generate_playlist_display() File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/content.py", line 155, in generate_playlist_display updated = yt_datetime(x.get('updated'))[1] File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/util.py", line 315, in yt_datetime time_obj = time.strptime(yt_date_time, "%Y-%m-%dT%H:%M:%S.%fZ") File "/usr/lib/python3.6/_strptime.py", line 559, in _strptime_time tt = _strptime(data_string, format)[0] File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime (data_string, format)) ValueError: time data '2014-09-11T04:00:48Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/sneeuwpop/.local/bin/mpsyt", line 8, in <module> sys.exit(main.main()) File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/main.py", line 148, in main if matchfunction(i.function, i.regex, userinput): File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/main.py", line 80, in matchfunction content.generate_songlist_display(zeromsg=g.message) File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/content.py", line 74, in generate_songlist_display return generate_playlist_display() File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/content.py", line 155, in generate_playlist_display updated = yt_datetime(x.get('updated'))[1] File "/home/sneeuwpop/.local/lib/python3.6/site-packages/mps_youtube/util.py", line 315, in yt_datetime time_obj = time.strptime(yt_date_time, "%Y-%m-%dT%H:%M:%S.%fZ") File "/usr/lib/python3.6/_strptime.py", line 559, in _strptime_time tt = _strptime(data_string, format)[0] File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime (data_string, format)) ValueError: time data '2014-09-11T04:00:48Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

Your Environment

OS: xubuntu 16.04

config

default config except that i use mpv with the "--video=no" args and I set it to search all video's not only music. Key Value order : relevance user_order : max_res : 2160p player : mpv playerargs : --video=no encoder : 0 [None] notifier : checkupdate : True show_mplayer_keys : True fullscreen : False show_status : True columns : ddir : /home/sneeuwpop/Downloads/mps overwrite : True show_video : False search_music : False window_pos : window_size : download_command : lastfm_username : lastfm_password : lastfm_api_key : lastfm_api_secret : audio_format : auto video_format : auto api_key : AIzaSyAGS34b5-x60_SFTOBZxthYslYrp4KlUtU autoplay : False set_title : True mpris : True

version

mpsyt version : 0.2.8 notes : released 17 February 2018 pafy version : 0.5.5 (youtube-dl backend) youtube-dl version : 2020.03.24 Python version : 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0] Processor : x86_64 Machine type : x86_64 Architecture : 64bit, ELF Platform : Linux-4.15.0-96-generic-x86_64-with-Ubuntu-18.04-bionic sys.stdout.enc : UTF-8 default enc : utf-8 Config dir : /home/sneeuwpop/.config/mps-youtube env:TERM : xterm-256color env:SHELL : /bin/bash env:LANG : en_US.UTF-8 env:LANGUAGE : en_US

oskarvid commented 4 years ago

I have run into this bug too, it only appears when I search for playlists, and I too have set mpsyt to also search for non music videos.
I think I was able to temporarily avoid this bug by running these commands:

rm -r /path/to/mps-youtube/mps_youtube/__pycache__
rm -r /home/user/.config/mps-youtube/cache_py_3.6.9
youtube-dl --rm-cache-dir

I have no idea if it was dumb luck and completely unrelated to the actual bug, it worked more than once before but when this bug happened just now this fix didn't work anymore.

justahuman1 commented 4 years ago

After a fresh reinstall and cache wipe, the issue is still persistent.

OS: 5.6.11-Arch1-1 Download: AUR

If someone knows a fix, that would be great. I'll check out the code when I get a chance. Since it's a date parsing issue from the Youtube end, it seems like a frontend change was made, which is throwing off the mps parser.

muzicstation commented 4 years ago

If you know the playlist URL or id. With the pl \<playlist url or id> command, it worked fine. It's not a solution to the problem, but I'm getting by with this for the time being.