- Some shows list episodes in the wrong order so reverse sort them by release date (fixes #11)

This commit is contained in:
Frank de Lange 2022-05-24 12:09:03 +00:00
parent 2a10ec3332
commit c0f76f5290
4 changed files with 7 additions and 3 deletions

Binary file not shown.

BIN
dist/spodcast-0.4.9.tar.gz vendored Normal file

Binary file not shown.

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = spodcast name = spodcast
version = 0.4.8 version = 0.4.9
description = A caching Spotify podcast to RSS proxy. description = A caching Spotify podcast to RSS proxy.
long_description = file:README.md long_description = file:README.md
long_description_content_type = text/markdown long_description_content_type = text/markdown

View file

@ -2,6 +2,7 @@ import json
import logging import logging
import os import os
import time import time
from datetime import datetime
from html import escape from html import escape
import urllib.parse import urllib.parse
@ -59,11 +60,14 @@ def get_show_episodes(show_id_str) -> list:
f'{SHOWS_URL}/{show_id_str}/episodes', limit=limit, offset=offset) f'{SHOWS_URL}/{show_id_str}/episodes', limit=limit, offset=offset)
offset += limit offset += limit
for episode in resp[ITEMS]: for episode in resp[ITEMS]:
episodes.append(episode[ID]) episodes.append([episode[ID], episode[RELEASE_DATE]])
if len(resp[ITEMS]) < limit: if len(resp[ITEMS]) < limit:
break break
return episodes # some shows list episodes in the wrong order so reverse sort them by release date
episodes.sort(key=lambda x: datetime.strptime(x[1], "%Y-%m-%d"), reverse=True)
return [episode[0] for episode in episodes]
def download_file(url, filepath): def download_file(url, filepath):