Finding the URL for podcast feeds from an iTunes id. (iTMS API) - api

I'm look at a way of turning an iTunes podcast id into the RSS feed that the podcast producer serves.
I'm aware of the RSS generator, which can be used to generate a feed of links to podcasts, but these links are to HTML pages.
If you have iTunes open, you can manually export the list of podcasts by exporting to OPML, so we can surmise that iTunes eventually knows how to decode them (i.e. they're not exclusively going through an iTMS host).
I have looked at the Affiliate API document which gives you some nice JSON back. This gives you a collectionViewUrl which is the same as the ones given in the RSS generator, and incidentally, the iTunes Link Generator. It also give you the id, and a whole load of other things including a preview audio file which is not hosted on the phobos.
At this point, I'm looking for anything that would help me solve this question, including any language, unofficial or not.
(in actual fact, I'd prefer something vaguely supported, and in Java, that didn't involve HTML scraping).

Through a combination of answers from these two questions, I have found a way to do what I want.
Example of finding podcasts
First: grab a list of podcasts from iTunes, using the RSS generator. I'm not sure how the query parameters work yet, but here is an RSS feed for top tech podcasts in the US.
http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppodcasts/sf=143441/limit=25/genre=1318/xml
sf relates to country, and is optional. I would guess that this defaults to global if absent.
genre relates to genre, and is optional. I would guess that this defaults to "all genres" is absent.
limit is optional, and seems to default to 9.
This gives you an Atom feed of podcasts. You'll need to do some sperlunking with XPath to get to the ITMS id of podcast, but you're looking for the numeric id contained in the URL found at the following XPath:
/atom:feed/atom:entry/atom:link[#rel='alernate']/#href
For example, the excellent JavaPosse has an id of 81157308.
The Answer to the Question
Once you have that id, you can get another document which will tell you the last episode, and the original feed URL. The catch here is that you need to use an iTunes user-agent to get this document.
e.g.
wget --user-agent iTunes/7.4.1 \
--no-check-certificate \
"https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/com.apple.jingle.app.finance.DirectAction/subscribePodcast?id=81157308&wasWarnedAboutPodcasts=true"
This is a plist containing some metadata about the podcast, including the feed URL.
<key>feedURL</key><string>http://feeds.feedburner.com/javaposse</string>
The XPath for this could be something like:
//key[#text='feedURL']/following-sibling::string/text()
Disclaimer
Not entirely sure how stable any of this is, or how legal it is. YMMV.

As soon as you have the id you can use it in lookup as defined in
https://performance-partners.apple.com/search-api
You should get what you need by parsing the response with JSON

To elaborate on #juhariis' answer, here's the basics of extracting the feed url from the json (python3):
from urllib.request import urlopen
from urllib.parse import urlparse
import codecs
import json
podcast_url = 'https://itunes.apple.com/us/podcast/grow-big-always/id1060318873'
ITUNES_URL = 'https://itunes.apple.com/lookup?id='
parsed = urlparse(podcast_url)
id = parsed.path.split('/')[-1][2:]
reader = codecs.getreader('utf-8')
with urlopen(ITUNES_URL + id) as response:
feed = json.load(reader(response))['results'][0]['feedUrl']
print(feed)
Here's a script/module I made, that makes use of this: https://gist.github.com/theychx/f9fad123bef27bebac665847c7884cd9

I searched for a long time to deconstruct the iTunes podcast feed. It's a plist containing meta data, of which one of them is an RSS feed. My blog post How to subscribe to iTunes podcasts on Android has links to code in php and in javascript to extract the URL to the RSS feed from an individual iTunes link.

Related

How can I get a random article in a specific category from the Wikipedia API?

This is my link for getting one random article using Wiki API:
https://en.wikipedia.org/w/api.php?%20format=json&action=query&prop=extracts&exsentences=2&exintro=&explaintext=&generator=random&grnnamespace=0
I need to get from it the first two sentences of the first section, and it works pretty well.
I want to use this kind of link and search this random article in a specific category. This is what I have tried after searching online:
https://en.wikipedia.org/w/api.php?%20format=json&action=query&prop=extracts&exsentences=2&exintro=&explaintext=&generator=random&grnnamespace=0&cmtitle=Category:Music
(I have added this part to the original link: cmtitle=Category:Music )
It doesn't work for me.
It gets the random article like the first link (not under a wanted category, which is Music in this link).
There is no API to get a random category member (and using a parameter from some unrelated API module is certainly not going to help). You could screen scrape Special:RandomInCategory (or turn it into an API module - patches welcome :)
try to use cmlimit to get all of the catgeorymembers, then use a programming language, like Python to request the page, then store every catgeory in an array, and use the random module to get a random catgeorymember from the array you stored them in. then you can use it in a link to get the specific page for the categorymember or anything else that you need.

Google CardDAV changes vCard UID

I'm integrating the Google CardDAV with my webApplication. I have a strange problem sometimes when I make a PUT of a new vCard.
If the vCard contains a UID and the UID is a GUID Google changes the vCard UID with a 16-char UID.
for example: This is my original vCard
BEGIN:VCARD
VERSION:3.0
N:Pinch;David;;;
FN:David Pinch
REV:2013-01-09T09:26:34Z
UID:6c34bedcf256408780d8ffe269ec2b3b
END:VCARD
So I PUT this into Google CardDAV, into the current url:
https://www.google.com/m8/carddav/principals/__uids__/myusername#gmail.com/lists/default/6c34bedcf256408780d8ffe269ec2b3b
The result is ok, and the contact is really created on Google Contacts.
BUT:
if "now" I retrieve the current vCard from the same URL i have the following response.
BEGIN:VCARD
VERSION:3.0
N:Pinch;David;;;
FN:David Pinch
REV:2013-01-09T09:44:25Z
UID:716212e795884e43
END:VCARD
You can see that UID has changed and passed from original
UID:6c34bedcf256408780d8ffe269ec2b3b
To
UID:716212e795884e43
Curiously if I retrieve the card with the following Request
https://www.google.com/m8/carddav/principals/__uids__/myusername#gmail.com/lists/default/716212e795884e43
I have Exactly the same Response, like the vCard references two different Path url.
However when i retrieve the list of the contact from CardDAV, this return the second URL.
If I does not create the vCard with a GUID but with a 16-char UID, Seems that Google accept this, but sometimes it changes However, so I cannot be sure of the uniqueness of the Card.
A workaround seem to be of re-download the vCard after every PUT, but this causes a payload important that I wanted to avoid.
I use the same procecures with iCloud CardDAV and this doesn't happen.
Anyone can help me?
When you PUT a vCard to Google CardDAV it will recreate a new vCard V3.0 and dispose the original data posted including data loss and the UID / URI path changes you describe.
Other then UID change Google CardDAV has other issues
Data loss
Rejection of valid vCards
Slowness (10-20s per write
operation)
More details in the following Google CardDAV stress test article:
https://evertpot.com/google-carddav-issues/
My advise after still seeing these failures in 2018: its better to use Google's Contacts API instead of there CardDAV implementation.

Getting text information from the Internet into my app

I learning Objective C, and I am going to develop some apps. I have a general question: How to get text information from the Internet into your app. Say you want the current title of Yahoo News. Do I need to use some PHP, or are there Objective-C specific classes to choose from?
Help is appreciated (code as well!), just anything that can help me take te step to exploring the new possibilities!
If I understand your question, I'd say the best way to do it would be to get the HTML source from the URL of your choosing as a string, then parse it to grab an attribute such as the title. Have a look at NSString and NSXMLDocument; they both let you instantiate them from a URL.
Here's a great way to do it:
Go to Yahoo Pipes, and create your "pipe" (basically a feed of one or many different data inputs on the web).
Publish: Select a format for Yahoo to host, for example as an RSS feed or in JSON.
UIWebView can then point to your pipe's URL. (Here's a tutorial on UIWebView)
Done.
Note that you can choose to get the feed as RSS, JSON, and other formats as well. Here is an example of a pipe I set up for the National Vulnerabilities Database as RSS, and the same feed as JSON.
ASIHttpRequest Will keep you sane.

Is it possible to get a RSS feed of a reddit with links to posts with X upvotes?

I created a subreddit that I am connecting to a twitter account via twitterfeed.
Currently I have it pointed to this RSS feed.
I would like to filter this RSS feed with posts that have X upvotes such that only the good posts reach the Twitter account. Is there a way to do this? via API or otherwise?
Ignore the RSS feed.
Use this..
http://code.reddit.com/wiki/API
Use the url with a .json appended to whatever category you are interested in.
Note the score property. There is no way to send over a query but you can simply ignore those that don't have the score you are looking for.
Yahoo Pipes is amazing for feed things like this.
This should do what you want (and if it doesn't, you can easily tweak it; Pipes is pretty easy):
http://pipes.yahoo.com/pipes/pipe.info?_id=16d40aa3cb2958bd814ee8ced0f62538
Maybe you need to scrape the page and generate your own RSS feed. That should be a simple job for a scraper.

While making an RSS reader which saves articles, how can I prevent duplicates?

Lets say I have a RSS feed which lists the 3 newest questions on SO. At 1 o'clock, the feed looks like this:
While making an RSS reader which saves articles, how can I prevent duplicates?
Convert char array to UNICODE in MFC C++
How to deploy a Java Swing application with an embedded JavaDB database?
At 2 o'clock, this feed looks like:
django url from another template than the one associated with the view-function
While making an RSS reader which saves articles, how can I prevent duplicates?
Convert char array to UNICODE in MFC C++
(duplicate articles are bold)
I want to download the RSS feed every 5 minutes, parse it and save the articles that aren't already saved, but I do not want duplicates (items that remain in the new, updated feed like the examples above). What can I use to determine if an article is already saved? Thanks
In theory, you can just use guid for RSS 2, and id for Atom. These are each supposed to be permanent and unique. However, in practice some sites don't conform to this, so you have to use heuristics.