Pull iTunes raw feed out of iTunes url

This iTunes thinggy somehow qualifies as yet-another-apple-tech-rape: just some old tech behind iron curtains…
master
pictuga 2014-05-12 23:15:51 +02:00
parent d8074d6b6d
commit b7136f2056
2 changed files with 15 additions and 2 deletions

View File

@ -96,6 +96,13 @@ def PreWorker(url, cache):
cache.set('redirect', nurl)
cache.set('cache', ncache)
if urlparse.urlparse(url).netloc == 'itunes.apple.com':
match = re.search('/id([0-9]+)(\?.*)?$', url)
if match:
iid = match.groups()[0]
redirect = 'https://itunes.apple.com/lookup?id={id}'.format(id=iid)
cache.set('redirect', redirect)
class Builder(object):
def __init__(self, link, data=None, cache=False):
self.link = link

View File

@ -543,7 +543,9 @@ def Fetch(url, cache, options):
cache.set('etag', con.headers.getheader('etag'))
cache.set('lastmodified', con.headers.getheader('last-modified'))
if xml.startswith('<?xml') or con.info().type in MIMETYPE['xml']:
if url.startswith('https://itunes.apple.com/lookup?id='):
style = 'itunes'
elif xml.startswith('<?xml') or con.info().type in MIMETYPE['xml']:
style = 'normal'
elif feedify.supported(url):
style = 'feedify'
@ -557,7 +559,11 @@ def Fetch(url, cache, options):
log(style)
if style == 'normal':
if style == 'itunes':
link = json.loads(xml)['results'][0]['feedUrl']
log('itunes redirect: %s' % link)
return Fetch(link, cache.new(link), options)
elif style == 'normal':
rss = feeds.parse(xml)
elif style == 'feedify':
feed = feedify.Builder(url, xml, cache)