Skip to content

Instantly share code, notes, and snippets.

@stephensekula
Last active May 24, 2019 02:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephensekula/47820ab98ae44ae322325bf9df8b2162 to your computer and use it in GitHub Desktop.
Save stephensekula/47820ab98ae44ae322325bf9df8b2162 to your computer and use it in GitHub Desktop.
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