File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 11from zotify .const import ITEMS , ID , TRACK , NAME
22from zotify .termoutput import Printer
33from zotify .track import download_track
4- from zotify .utils import split_input
4+ from zotify .utils import split_input , strptime_utc
55from zotify .zotify import Zotify
66
77MY_PLAYLISTS_URL = 'https://api.spotify.com/v1/me/playlists'
@@ -37,6 +37,8 @@ def get_playlist_songs(playlist_id):
3737 if len (resp [ITEMS ]) < limit :
3838 break
3939
40+ songs .sort (key = lambda s : strptime_utc (s ['added_at' ]), reverse = True )
41+
4042 return songs
4143
4244
Original file line number Diff line number Diff line change @@ -282,3 +282,7 @@ def fmt_seconds(secs: float) -> str:
282282 return f'{ m } ' .zfill (2 ) + ':' + f'{ s } ' .zfill (2 )
283283 else :
284284 return f'{ h } ' .zfill (2 ) + ':' + f'{ m } ' .zfill (2 ) + ':' + f'{ s } ' .zfill (2 )
285+
286+ def strptime_utc (dtstr ):
287+ return datetime .datetime .strptime (dtstr [:- 1 ], '%Y-%m-%dT%H:%M:%S' ).replace (tzinfo = datetime .timezone .utc )
288+
You can’t perform that action at this time.
0 commit comments