Feed Import is a module that allows you to import content into entities from various file types (like XML, HTML, CSV).
In this page we will import some youtube videos and for media we will use media_youtube module.
Create content type
We have to create a new content type (admin/structure/types/add) named "Youtube videos" (with machine name youtube_videos).
Attach to this a new field "field_youtube" with type of "Multimedia asset".
(You can add another fields to hold author, views, ...)
Save your content type.
After I've added a new content I didn't see video player anywhere. In this issue I found some help but still video player appears only on front page if node is promoted. Please take a look if you have similar problems.
Create Feed Configuration
We will use an RSS feed to get most recent videos (this link might change): http://gdata.youtube.com/feeds/api/videos?alt=rss.
If you want you can get another one here.
Ok, now go to Feed Import and add new feed named "Youtube import", for entity select "node", for url set our feed url and for process function select "processXML".
Go and edit this feed.
For xpath parent use //item and don't use anything for xpath unique because this is a one time import to see how to work with media_youtube.
Now add the following fields:
title with xpath title with action if empty: "Skip importing this item"
field_youtube with xpath link
type with no xpath and default value set to youtube_videos (machine name for our content type, without this we cannot save a node)
promote with no xpath with default value set to 1 (we promote this on front page)
uid with no xpath and default value set to 1 (we set as author the admin).
Now save the feed and it's time to go to filters.
For field_youtube add the following filters (don't use quotes):
"Get media provider" with function name "media_internet_get_provider" and one param: [field]
"Save video" with function name "::callMethod" and two params: [field] and save
Save filters and go to process your feed. You should see on front page imported videos.
In reports you should find something like
Feed Youtube import imported. Started 08/12/2011 20:30:56, file downloaded & parsed 00:00:03, processing items 00:00:02, total duration 00:00:05, total feed items 25, rescheduled 0, updated 0, new 25, not imported 0.
Attachment | Size |
---|---|
youtube-content-type.png | 17.25 KB |
youtube-filters.png | 14.25 KB |
youtube-feed-new.png | 21.92 KB |
Comments
I managed to get this working
I managed to get this working thanks.
I have a few questions:
1. I am getting the same nodes twice. Could you explain how to set up cron properly. As above you say you just want to test it. I want to make it bring in new content and keep that content and not duplicate it.
2. How could we get the description from youtube to show in the body. And similarly the tags to the default drupal node tags.
I think the description and tags in particular are crucial.
thanks again, I have tried many times over the last year to get something to work but your tutorial has been the best so far.
John
Update: By trial and error I
Update:
By trial and error I discovered I could
add a
body
field and then put the xpath to description.
still need some way to stop refetching the same items already imported.
Use unique xpath
You have to fill the "Enter xpath to a unique identifier of item" textfield with guid xpath.
Please create an issue if still having problems.
I put "guid" in that field
I put "guid" in that field and I think I tried checking to see if
unpublishing items instead of deleting them would make them not reimport the next time. It seemed to work.
But later I processed again and wala,
items that I had imported and edited and wrote paragraphs about just got deleted.
I have gone back to square one and removed the guid, and looks like I have to do this manually lessly frequently to check for new content to work with.
thanks again.
mapping fields?
Hi there, thank you for posting these instructions -- managed to get it working -- can you advise how to map more fields? like date, description, etc?
Save RSS and map fields
Using the link provided above ("Here"). Save RSS and xml/xpath map fields to any of the defined fields
(ie: description >> body)
"Feed YouTube Import processed!" >> no nodes being created?-HELP
I have followed these directions and everything seems to be going well...
When I "Process" the feed I just get:
No nodes are created?
Please check report log for
Please check report log for more info about import process.
No nodes where importet here.
No nodes where importet here. I'm only getting the following in my watchdog:
Followed the tutorial. Dunno what's wrong hee.
type with no xpath and
Please read the tutorial more carefully.
Save content in full html
Hi,
Import works but i see html code in content. How can I force the node to be created in full html ?
(sorry for my bad english)
Filters
I have a problem... I'm on D7 with all the right modules, but I don't see the table you show in youtube-filters.png ... I have only a text field XPATH instead... I am missing a plug-in?
Thanks,
Mario
Are you sure that you are
Are you sure that you are using the right module? This tutorial is about Feed Import module.
user stats
any ideas how to get user stats such as views, likes, etc... into fields?
also, any ideas how to get the youtube teaser image link to connect with teaser image on drupal?