diff --git a/newswire.py b/newswire.py index 089612524..9fcfe7ca9 100644 --- a/newswire.py +++ b/newswire.py @@ -623,11 +623,61 @@ def xml_podcast_to_dict(base_dir: str, xml_item: str, xml_str: str) -> {}: return podcast_properties -def get_link_from_rss_item(rss_item: str) -> (str, str): +def get_link_from_rss_item(rss_item: str, + preferred_mime_types: [] = None, + proxy_type: str = None) -> (str, str): """Extracts rss link from rss item string """ mime_type = None + if preferred_mime_types and ' None: '' + \ 'https://anchor.fm/creativecommons/episodes/' + \ 'Hessel-van-Oorschot-of-Tribe-of-Noise--Free-Music-Archive-e1crvce' + \ - '' + \ - 'Wed, 12 Jan 2022 14:28:46 GMT' + \ + '\n' + \ + 'Wed, 12 Jan 2022 14:28:46 GMT\n' + \ '' - link, mime_type = get_link_from_rss_item(rss_item) + 'ccb5edffbac1.mp3" length="67247880" type="audio/mpeg"/>\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + \ + '\n' + + link, mime_type = get_link_from_rss_item(rss_item, None, None) assert link - assert link.endswith('.mp3') + assert link.endswith('1.mp3') assert mime_type assert mime_type == 'audio/mpeg' + link, mime_type = get_link_from_rss_item(rss_item, ['audio/opus'], None) + assert mime_type + if mime_type != 'audio/opus': + print('mime_type: ' + mime_type) + assert mime_type == 'audio/opus' + assert link + assert link == 'https://whoframed.rodger/rabbit.opus' + + link, mime_type = get_link_from_rss_item(rss_item, ['audio/opus'], 'tor') + assert mime_type + if mime_type != 'audio/opus': + print('mime_type: ' + mime_type) + assert mime_type == 'audio/opus' + assert link + assert link == 'http://randomaddress.onion/rabbit.opus' + rss_item = \ '' + \ 'https://anchor.fm/creativecommons/episodes/' + \