Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

php - get the latest podcasts from itunes store with link by RSS, JSON or something

i'm trying to get the latest podcast informations out of "itunes store" to work with this data in several applications (iphone app and web app).

Is there a way to get this informations? RSS, JSON or something?

i want to work with this informations in objective-c and on a website with php or js.

Is my question clear? :(

//edit: anything unclear? leave a comment, if yes

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Based on your question, I just tried to find a way to do this.

  1. So you'll need the podcast ID (should be obvious from the URL if you have it; for instance http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=82884735 has the ID "82884735", and http://itunes.apple.com/us/podcast/this-week-in-tech-mp3-edition/id73329404 has the ID "73329404").

  2. ???

  3. Plug the ID into the URL https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/com.apple.jingle.app.finance.DirectAction/subscribePodcast?id={ID}&wasWarnedAboutPodcasts=true and get the data, where {ID} is your podcast ID. It's important here to change your user agent string to iTunes. For this experiment, I used "iTunes/7.4.1". If you don't change it, you'll get something very different.

  4. You'll end up with XML data; an XML plist enclosed in Document and Protocol tags. It will look like

    <Document> <Protocol> <plist version="1.0"> ... </plist> </Protocol> </Document>

You can pull the plist data from this and use a library to manipulate it if your language of choice has one. Essentially there'll be a "root" dictionary and a dictionary inside it called "subscribe-podcast". This "subscribe-podcast" dictionary will have a key called "feedURL" – nab the value, and you'll have your RSS feed. I'd recommend trying these steps and following along.

An easier to follow representation of the plist is the NeXTSTEP format, which actually looks a bit like JSON. An excerpt of a dummy podcast plist transformed into this format is as follows (remember that you'll really be getting back an XML-like file):

{
    "subscribe-podcast" = {
        …
        feedURL = "http://feeds.feedburner.com/yaddayaddayadda"; 
        …
        podcastName = "Lorem Ipsum"; 
        …
    }; 
}

Now you'll notice in the steps I described that step 2 is missing. This is because I looked at the data that Apple was giving me back manually to get to the URL in step 3. Chances are that you'll want to parse the data yourself in case Apple decides to change the URL, but maybe it's probable for the intermediate HTML to change and break your program anyway. I might go back and look at documenting the steps that should be taken to get at our magic URL in step 3.

I tried out this strategy with a few podcasts, and it seems to work well in giving me the RSS feed. Since I don't know any of the languages that you asked for, I can't make any recommendations code-wise. Hope it can get you on your way, though.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...