473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Media RSS parsing in Perl

8
Hi,

I am trying to parse a rss similar to the one found here (in example) http://www.feedforall.com/mediarss.htm

<!-- Snipped for Brevity -->
Expand|Select|Wrap|Line Numbers
  1. <item>
  2. <title>FeedForAll's Show Tunes and Song</title>
  3. <link>http://www.feedforall.com/songs.htm</link>
  4. <description>FeedForAll cool show tunes and lyrics. </description>
  5. <media:group>
  6. <media:content url="http://www.feedorall.com/sample.mp3" fileSize="122345" type="audio/mpeg" isDefault="true" expression="sample" bitrate="128" framerate="24" duration="98" height="220" width="300" />
  7. <media:adult> false </media:adult>
  8. <media:title> FeedForAll file sample </media:title>
  9. <media:hash> dfdec888b72151965a34b4b59031290a </media:hash>
  10. <media:player url="http://www.feedforall.com/player" height="220" width="300" />
  11. <media:credit role="author"> J Housley </media:credit>
  12. <media:text type="plain"> FeedForAll supports name space extentions, specifically Yahoo's media RSS </media:text>
  13. </media:group>
  14. </item>
  15.  
<!--Snipped for Brevity-->

Now I want to get media:title, media:player url etc. I am trying to use XML::RSS, but no luck yet :(

Please help.

Thanks,
Subeen.
Sep 15 '07 #1
4 4430
numberwhun
3,509 Expert Mod 2GB
Hi,

I am trying to parse a rss similar to the one found here (in example) http://www.feedforall.com/mediarss.htm

<!-- Snipped for Brevity -->
Expand|Select|Wrap|Line Numbers
  1. <item>
  2. <title>FeedForAll's Show Tunes and Song</title>
  3. <link>http://www.feedforall.com/songs.htm</link>
  4. <description>FeedForAll cool show tunes and lyrics. </description>
  5. <media:group>
  6. <media:content url="http://www.feedorall.com/sample.mp3" fileSize="122345" type="audio/mpeg" isDefault="true" expression="sample" bitrate="128" framerate="24" duration="98" height="220" width="300" />
  7. <media:adult> false </media:adult>
  8. <media:title> FeedForAll file sample </media:title>
  9. <media:hash> dfdec888b72151965a34b4b59031290a </media:hash>
  10. <media:player url="http://www.feedforall.com/player" height="220" width="300" />
  11. <media:credit role="author"> J Housley </media:credit>
  12. <media:text type="plain"> FeedForAll supports name space extentions, specifically Yahoo's media RSS </media:text>
  13. </media:group>
  14. </item>
  15.  
<!--Snipped for Brevity-->

Now I want to get media:title, media:player url etc. I am trying to use XML::RSS, but no luck yet :(

Please help.

Thanks,
Subeen.
Could you please post your code so that we can see what you have been trying thus far? Also, when posting your code, please do not forget the code tags as explained in the REPLY GUIDELINES to the right of the reply window.

Regards,

Jeff
Sep 16 '07 #2
subeen
8
Here is what I am trying to do:
Expand|Select|Wrap|Line Numbers
  1. $rss->parse($raw);
  2. foreach my $item (@{$rss->{'items'}})
  3. {
  4.     $title = $item->{'title'};
  5.     $media_keywords = $item->{'media:keywords'};
  6.     print $title, "\n";
  7.     print $media_keywords, "\n";
  8. }
  9.  
It prints the title, but doesn't print the keywords.
Sep 17 '07 #3
subeen
8
I have changed the code.

Expand|Select|Wrap|Line Numbers
  1. $rss->add_module(prefix=>'dc', uri=>"http://purl.org/dc/terms/");
  2. $rss->add_module(prefix=>'media', uri=>"http://search.yahoo.com/mrss");
  3. $rss->parse($raw);
  4.  
  5. foreach my $item (@{$rss->{'items'}})
  6. {
  7.     $title = $item->{'title'};
  8.     $media_keywords = $item->{'media'}->{'keywords'};
  9.     $media_player_url = $item->{'media'}->{'player'}->{'url'};
  10.     print $title, "\n";
  11.     print $media_keywords, "\n";
  12.     print $media_player_url, "\n";
  13. }
  14.  
Now it prints the title & keywords, but doesn't print the media player url.
Sep 17 '07 #4
numberwhun
3,509 Expert Mod 2GB
I have changed the code.

Expand|Select|Wrap|Line Numbers
  1. $rss->add_module(prefix=>'dc', uri=>"http://purl.org/dc/terms/");
  2. $rss->add_module(prefix=>'media', uri=>"http://search.yahoo.com/mrss");
  3. $rss->parse($raw);
  4.  
  5. foreach my $item (@{$rss->{'items'}})
  6. {
  7.     $title = $item->{'title'};
  8.     $media_keywords = $item->{'media'}->{'keywords'};
  9.     $media_player_url = $item->{'media'}->{'player'}->{'url'};
  10.     print $title, "\n";
  11.     print $media_keywords, "\n";
  12.     print $media_player_url, "\n";
  13. }
  14.  
Now it prints the title & keywords, but doesn't print the media player url.
Unfortunately, I know nothing about this module, but have you tried running the media player line as:

Expand|Select|Wrap|Line Numbers
  1. $media_player_url = $item->{'media'}->{'player'};
  2.  
and see what it returns? I would play with it and see what happens. It may just be a formatting issue of the command.

Regards,

Jeff
Sep 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
3
by: Wayne Folta | last post by:
I hadn't really followed the state of perl for quite a few years. When Irecently found python, it just suited me and now I've switched. (And am contributing to an open-source python project. Great...
3
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
35
by: .:mmac:. | last post by:
I have a bunch of files (Playlist files for media player) and I am trying to create an automatically generated web page that includes the last 20 or 30 of these files. The files are created every...
8
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
2
by: Sandman | last post by:
Ok, so I'm the author of a pretty big CMS system (big as in huge, not market-share big) and I've been thinking about a problem for a few weeks here on media management. The CMS accomodates both...
1
by: Robert Neville | last post by:
Basically, I want to create a table in html, xml, or xslt; with any number of regular expressions; a script (Perl or Python) which reads each table row (regex and replacement); and performs the...
4
by: R Wood | last post by:
Greetings - A recent Perl experiment hasn't turned out so well, which has piqued my interest in Python. The project is this: take a Vcard file exported from Apple's Addressbook and use a...
1
by: worlman385 | last post by:
I need to parse the following HTML page and extract TV listing data using VC++ http://tvlistings.zap2it.com/tvlistings/ZCGrid.do any good way to extract the data? is easy for VC++ to call...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.