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.

Feed Import Youtube 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".

Feed Import Youtube New Feed

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
Feed Import Youtube Filters
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.

AttachmentSize
youtube-content-type.png17.25 KB
youtube-filters.png14.25 KB
youtube-feed-new.png21.92 KB

Comments

brisbanett’s picture

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

brisbanett’s picture

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.

Sorin Sarca’s picture

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.

brisbanett’s picture

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.

zopa’s picture

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?

stevegmag’s picture

Using the link provided above ("Here"). Save RSS and xml/xpath map fields to any of the defined fields
(ie: description >> body)

stevegmag’s picture

I have followed these directions and everything seems to be going well...

When I "Process" the feed I just get:

Feed YouTube Import processed!

No nodes are created?

Sorin Sarca’s picture

Please check report log for more info about import process.

Peter Majmesku’s picture

No nodes where importet here. I'm only getting the following in my watchdog:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7562 of my-web/includes/common.inc).

Followed the tutorial. Dunno what's wrong hee.

Sorin Sarca’s picture

type with no xpath and default value set to youtube_videos (machine name for our content type, without this we cannot save a node)

Please read the tutorial more carefully.

Tourist’s picture

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)

dotnhack’s picture

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

Sorin Sarca’s picture

Are you sure that you are using the right module? This tutorial is about Feed Import module.

guptro242’s picture

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?