source: trunk/as3/com/jeroenwijering/parsers/ItunesParser.as @ 211

Revision 211, 1.0 KB checked in by jeroen, 4 years ago (diff)

added a Logger class for debugging.

Line 
1/**
2* Parse Itunes specific RSS feed content into playlists.
3**/
4package com.jeroenwijering.parsers {
5
6
7import com.jeroenwijering.utils.Strings;
8
9
10public class ItunesParser {
11
12
13        /** Prefix for the iTunes namespace. **/
14        private static const PREFIX = 'itunes';
15
16
17        /**
18        * Parse a feedentry for iTunes content.
19        *
20        * @param obj    The XML object to parse.
21        * @param itm    The playlistentry to amend the object to.
22        * @return               The playlistentry, amended with the iTunes info.
23        * @see                  RSSParser
24        **/
25        public static function parseEntry(obj:XML,itm:Object):Object {
26                for each (var i:XML in obj.children()) {
27                        if(i.namespace().prefix == ItunesParser.PREFIX) {
28                                switch(i.localName().toLowerCase()) {
29                                        case 'author':
30                                                itm['author'] = i.text().toString();
31                                                break;
32                                        case 'duration':
33                                                itm['duration'] = Strings.seconds(i.text().toString());
34                                                break;
35                                        case 'summary':
36                                                itm['description'] = i.text().toString();
37                                                break;
38                                        case 'keywords':
39                                                itm['tags'] = i.text().toString();
40                                                break;
41                                }
42                        }
43                }
44                return itm;
45        }
46
47
48}
49
50
51}
Note: See TracBrowser for help on using the repository browser.