Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RSS Liberator (from iTunes Feed)
#!/usr/bin/env python3
import subprocess
import re
import sys
import json
re_iTunes = re.compile('http.*id([0-9]+)')
url_iTunes = sys.argv[1]
print("Converting iTunes URL (%s) to JSON retrieval link for podcast" % (url_iTunes))
podcast_id = 0
match_result = re_iTunes.match(url_iTunes)
if match_result != None:
podcast_id = match_result.group(1)
pass
if podcast_id == 0:
sys.exit()
pass
url_json = 'https://itunes.apple.com/lookup?id=%d&entity=podcast' % (int(podcast_id))
print("JSON URL: %s" % url_json)
# Retrieve the JSON file
subprocess.check_output('curl -s -o podcast.json %s' % (url_json), shell=True)
try:
podcast_file = open('podcast.json','r')
podcast_data = json.loads(podcast_file.read())
print("================= Actual RSS Feed URL =================")
print(podcast_data['results'][0]['feedUrl'])
print("=======================================================")
except:
print("Unable to open the JSON file")
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.