Getting Enclosure Contents using Rome RSS parser

G

galois271

Hi all,

I just downloaded Rome to use in my podcast catching program. I can't seem to find any decent documentation on it. I am trying to access the podcast URLs that are located in the enclosures.

Here is what I tried: (everything works great, but getting enclosure contents/values)

public static void main(String[] args) throws IOException, IllegalArgumentException, FeedException
{
URL url = new URL("http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU");
XmlReader reader = null;

try {

reader = new XmlReader(url);
SyndFeed feed = new SyndFeedInput().build(reader);
System.out.println("Feed Title: " + feed.getAuthor());

for (@SuppressWarnings("rawtypes")Iterator i = feed.getEntries().iterator(); i.hasNext();)
{
SyndEntry entry = (SyndEntry) i.next();
System.out.println("Title: " + entry.getTitle());
System.out.println("Description: " + entry.getDescription().getValue());
System.out.println("Link: " + entry.getEnclosures() + '\n');

}
} finally {
if (reader != null)
reader.close();

}
}

}
 
J

Jeff Higgins

I can't seem to find any decent documentation on it.
No javadoc available? I'd really want that.
What does getEnclosures() return? A bag/box/bunch of enclosures?
 
J

Jeff Higgins

I can't seem to find any decent documentation on it.
No javadoc available? I'd really want that.
What does getEnclosures() return? A bag/box/bunch of enclosures?
Maybe once you have an enclosure there is some sort of content
extraction tool.
 
C

Chuck Johnson

I can't seem to find any decent documentation on it.

No javadoc available? I'd really want that.

What does getEnclosures() return? A bag/box/bunch of enclosures?

It apparently returns a List, but I can't seem to use indexes to get the members. ??
 
L

Lew

Chuck said:
It apparently returns a List, but I can't seem to use indexes to get the members. ??

First of all, OP, don't ever do this:

@SuppressWarnings("rawtypes") ...

Second, give us this, please:

http://sscce.org/

As to docs for Rome, where have you looked so far?
 
C

Chuck Johnson

First of all, OP, don't ever do this:
@SuppressWarnings("rawtypes") ...



Second, give us this, please:



http://sscce.org/



As to docs for Rome, where have you looked so far?

I suppressed warnings because I'm just trying to get Rome to work, and that was a way recommended by Eclipse, sort of a TDD approach: make it so it doesn't fail. I'm really only testing Rome at the moment, no serious code.
Secondly, you have all my code, save the import statements and class declaration. Unless, you have Rome & JDOM installed, this code won't run for you. My hope is that one of you guys out there has actually used Rome before, and can help me.
 
C

Chuck Johnson

I suppressed warnings because I'm just trying to get Rome to work, and that was a way recommended by Eclipse, sort of a TDD approach: make it so it doesn't fail. I'm really only testing Rome at the moment, no serious code.

Secondly, you have all my code, save the import statements and class declaration. Unless, you have Rome & JDOM installed, this code won't run for you. My hope is that one of you guys out there has actually used Rome before, and can help me.

The rometools link didn't help. On that site, are a bunch of dead links. :(
 
J

Jeff Higgins

and that was a way recommended by Eclipse,

??

sort of a TDD approach: make it so it doesn't fail.

TDD approach? really? I'll have to look into your no-fail approach.
] hadn't heard of it before.

I'm really only testing Rome at the moment, no serious code.
Secondly, you have all my code, save the import statements and class
declaration.
Unless, you have Rome& JDOM installed, this code won't run for you.

As things stand there is no need for anyone to run the code.

My hope is that one of you guys out there has actually used Rome before,
and can help me.

Hasn't sunk in yet?

The rometools link didn't help. On that site, are a bunch of dead
links. :(

The frownny is funny.
 
L

Lew

Chuck said:
[attribution restored: please attribute citations]
Lew said:
First of all, OP, don't ever do this:

@SuppressWarnings("rawtypes") ...

Second, give us this, please:

http://sscce.org/

As to docs for Rome, where have you looked so far?

I suppressed warnings because I'm just trying to get Rome to work,

A) Not relevant.
B) Not really going to do what you intend.
C) Don't use raw types.
and that was a way recommended by Eclipse,
Nonsense.

sort of a TDD approach: make it so it doesn't fail.

That's rather the opposite of TDD.
I'm really only testing Rome at the moment, no serious code.

Okay, not really a good reason to indulge in bad habits, but okay ...
Secondly, you have all my code, save the import statements and class declaration.

"... all ... save ..." is not the same as "all".

And I didn't ask for all your code, I asked for an SSCCE.
Unless, you have Rome & JDOM installed, this code won't run for you.
My hope is that one of you guys out there has actually used Rome before, and can help me.

I had no troubles with the linked project site. The Javadocs downloaded just fine. DId you
try them?
 
R

Roedy Green

I can't seem to find any decent documentation on it

IntelliJ Idea and presumable most other IDES have a feature to let you
point at reference and see all the possible methods you could call on
it. It will then show you the parms and individual method needs.
These are invaluable for navigating through code that parses
something.
 
C

Chuck Johnson

I had no troubles with the linked project site. The Javadocs downloaded just fine. DId you

try them?

I am not really sure how to use javadocs to find what I'm looking for. I don't know what class or what methods to look at. I'm pretty sure there a lots & lots of methods, so I would probably spend hours & hours looking for the right method(s). I was looking more for a wiki/tutorial, or someone who has used it before.

Thanks, though.
 
L

Lew

Chuck Johnson wrote:

Again, please attribute citations. Did you not notice this request before?

[Lew wrote:]
I am not really sure how to use javadocs to find what I'm looking for. I don't know what class or what

Lots and lots of reading. Start with the summary of packages and work from there.
methods to look at. I'm pretty sure there a lots & lots of methods, so I would probably spend hours &
hours looking for the right method(s).

You say that as if it were a reason not to do it. It isn't. That would be time very well spent.

And the Rome Javadocs aren't all /that/ huge.
I was looking more for a wiki/tutorial, or someone who has
used it before.

Too bad. Instead of rejecting the help you are getting in favor of the help you're not,
get over it and accept the help you are getting.
Thanks, though.

No need to get snarky. Just follow the advice.

But since you don't like our advice, or our links, or respect requests for an SSCCE, try here:

http://lmgtfy.com/?q=Java+Rome+RSS+library

There seem to be some useful links there.
 
A

Arne Vajhøj

Chuck said:
[attribution restored: please attribute citations]
Lew said:
First of all, OP, don't ever do this:

@SuppressWarnings("rawtypes") ...

Second, give us this, please:

http://sscce.org/

As to docs for Rome, where have you looked so far?

I suppressed warnings because I'm just trying to get Rome to work,

A) Not relevant.
B) Not really going to do what you intend.
C) Don't use raw types.

Why not tell him what you do when you are using a library
that has a method that return a raw type!!!!

Arne
 
J

Jeff Higgins

Chuck said:
[attribution restored: please attribute citations]
Lew wrote:
First of all, OP, don't ever do this:

@SuppressWarnings("rawtypes") ...

Second, give us this, please:

http://sscce.org/

As to docs for Rome, where have you looked so far?

I suppressed warnings because I'm just trying to get Rome to work,

A) Not relevant.
B) Not really going to do what you intend.
C) Don't use raw types.

Why not tell him what you do when you are using a library
that has a method that return a raw type!!!!
Well, you have a point but:
Chuck has demonstrated only a serious lack of gumption.
Here is what I tried: (everything works great, but getting enclosure
contents/values)
And then copy pasted a few lines from some web site and added a single
(misguided) line at the end, but hasn't shown that he understands any
of it.

I can't find the docs.
I can't read the docs.
I guess it returns a List, what now boss?
It will take a lot of time.
It will take a lot of effort
I was looking more for a wiki/tutorial, or someone who has used it before.

comp.lang.java.rentaprogrammer/tutor is <thataway>
 
J

Jeff Higgins

Chuck Johnson wrote:
[snip]

And I didn't ask for all your code, I asked for an SSCCE.

How much smaller and more self contained do you imagine it could be?
Chuck hasn't provided any SSCCE, at lease not anything in the true spirit.
 
C

Chuck Johnson

On 30/04/13 21:59, Lew wrote:
Chuck Johnson wrote:

How much smaller and more self contained do you imagine it could be?

Chuck hasn't provided any SSCCE, at lease not anything in the true spirit..

1) I wasn't being snarky in the least. I was sincerely thankful.

2) I'm a working student who is just working on a personal project for fun;I don't have lots of time. I did this same project in Python and it took me nowhere near the time it is taking me in Java. I guess it's my naive belief that a programmer should be able to reuse someone's code without spending as much time studying it as it would to just write my own.

3) As for the SSCCE, I don't know what more I can give you. Like I said before in my first post, you have all the code I've wrote, save the import statements and class declaration, which I didn't include because I was trying to adhere to SSCCE.
 
J

Jeff Higgins

On 30/04/13 21:59, Lew wrote:
Chuck Johnson wrote:

And I didn't ask for all your code, I asked for an SSCCE.

How much smaller and more self contained do you imagine it could be?

Chuck hasn't provided any SSCCE, at lease not anything in the true spirit.

1) I wasn't being snarky in the least. I was sincerely thankful.

I don't recall anyone accusing you of being snarky.
2) I'm a working student who is just working on a personal project for fun; I don't have lots of time.
I did this same project in Python and it took me nowhere near the time
it is taking me in Java.

Python is a great programming environment.
Java is a great programming environment.

I guess it's my naive belief that a programmer should be able to reuse
someone's code
without spending as much time studying it as it would to just write my own.

??
3) As for the SSCCE, I don't know what more I can give you.
Like I said before in my first post, you have all the code I've wrote,
save the import statements and class declaration,
which I didn't include because I was trying to adhere to SSCCE.Ill ask again. What does .getEnclosures() return?
Have you found the Javadocs.
Javadocs are the key to programming with Java libraries.
What happens when you:
System.out.println(new ArrayList<String>());

In the code you provided you reference:
SyndFeed
SyndFeedInput
SyndEntry
What are these classes, what method do they expose?
I don't need to know, you do.
getEnclosures()
presumably there is an Enclosure class.
Does it provide a getScent() method?
The Javadocs will answer.
Study the Collections API. You can google it.
Study Java Generics, and her relation to the Collections API. You can
google it.
 
J

Jeff Higgins

2) I'm a working student who is just working on a personal project for fun; I don't have lots of time.

Noone have as much as they would like. It's a juggling act.

I did this same project in Python and it took me nowhere near the time
it is taking me in Java.

All depends on what you hope to accomplish.
If you hope to learn a particular programming language and environment
you'll need to spend the time and effort.
If you're hoping to mash up a particular application, well, you know the
rest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top