|
Revision 1, 1.0 kB
(checked in by jeroen, 18 months ago)
|
|
initial commit of old repository into public one
|
| Line | |
|---|
| 1 | /** |
|---|
| 2 | * Parses Agriya playlists and returns an indexed array with all elements |
|---|
| 3 | * |
|---|
| 4 | * @author Jeroen Wijering |
|---|
| 5 | * @version 1.0 |
|---|
| 6 | **/ |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | import com.jeroenwijering.feeds.AbstractParser; |
|---|
| 10 | import com.jeroenwijering.utils.StringMagic; |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | class com.jeroenwijering.feeds.AgriyaParser extends AbstractParser { |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | /** Contructor **/ |
|---|
| 17 | function AgriyaParser() { super(); }; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | /** Convert Agriya structure to array **/ |
|---|
| 21 | private function parse(xml:XML):Array { |
|---|
| 22 | var arr = new Array(); |
|---|
| 23 | var tpl = xml.firstChild.firstChild.firstChild; |
|---|
| 24 | while(tpl != null) { |
|---|
| 25 | if (tpl.nodeName.toLowerCase() == "video") { |
|---|
| 26 | var obj = new Object(); |
|---|
| 27 | obj['file'] = tpl.attributes.Path; |
|---|
| 28 | obj['image'] = tpl.attributes.Thumbnail; |
|---|
| 29 | obj['title'] = tpl.attributes.Description; |
|---|
| 30 | if(obj["file"].substr(0,4) == "rtmp") { |
|---|
| 31 | obj["type"] = "rtmp"; |
|---|
| 32 | } else if(obj['file'].indexOf('youtube.com') > -1) { |
|---|
| 33 | obj["type"] = "youtube"; |
|---|
| 34 | } else { |
|---|
| 35 | obj['type'] = obj["file"].substr(-3).toLowerCase(); |
|---|
| 36 | } |
|---|
| 37 | arr.push(obj); |
|---|
| 38 | } |
|---|
| 39 | tpl = tpl.nextSibling; |
|---|
| 40 | } |
|---|
| 41 | return arr; |
|---|
| 42 | }; |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | } |
|---|