Closed (fixed)
Project:
YouTube Field
Version:
8.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Mar 2020 at 05:58 UTC
Updated:
23 May 2020 at 23:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
megachrizTargets for fields provided by a contrib module, should go in that contrib module, so moving this issue to the YouTube Field issue queue.
Comment #3
scorpionghost commentedThanks
Comment #4
guschilds commentedHi ScorpionGhost,
Support for feeds was added to the 7.x version of the module in #1789844: Support for Feeds and later ported to Drupal 8. You'll find
youtube_feeds_processor_targets_alter()andyoutube_set_target()in youtube.module. I didn't do the Drupal 8 port and don't know much about Drupal 8 & Feeds, but that's the place to look first. If you find that it works as needed, please close this issue. If it doesn't work, please try to provide a patch that does. Thanks!Comment #5
megachriz@guschilds
The hook
hook_feeds_processor_targets_alter()(and other Feeds hooks) no longer exist in the D8 version of Feeds. I see that the methodsyoutube_feeds_processor_targets_alter()andyoutube_set_target()are still present in the D8 version of this project, but that's basicallydeadredundant code now.In the D8 version of Feeds, targets are plugins. You would need to create a FeedsTarget plugin for it. I've written some instructions for it in #2997019: Mapping for Ubercart Price and Attributes For Drupal 8 (still need to revise that and add it to the offical documentation).
Comment #6
guschilds commentedInteresting. Thanks MegaChriz! I'm not surprised that it's a plugin and not a hook these days. That documentation looks really helpful.
ScorpionGhost, If you're able to create a patch with the plugin, I'd be happy to review it. I can't make any promises regarding when I'll be able to try and do it myself.
Comment #7
marc.groth commented@MegaChriz thank you so much for providing such detailed instructions on how to implement this. Thanks to you I was able to create a very simple feed importer for YouTube video data. The importer will allow you to set both the Video URL and Video ID.
It would be awesome if somebody else could test and verify the patch/functionality. You can do so as follows:
1. Add the patch to your composer.json (under extras > patches) e.g.:
2. Run 'composer install' which should remove/re-add the module with the patch applied.
3. Clear the cache
That's it! From there you should be able to map any 'YouTube Video' field. I have applied the attached patch to my project using composer and it works really well.
Comment #8
marc.groth commentedSorry the formatting on the last patch was messed up for some reason. I've re-attached the correctly formatted patch. Please review/test against this one.
Comment #9
marc.groth commentedAhh third time's the charm haha. Just found a few more formatting issues. Updated patch attached.
Comment #10
guschilds commentedHi marc.groth,
Thanks for the patch! A couple of questions before I test it:
Thanks!
Comment #11
marc.groth commentedHey @guschilds,
Comment #12
guschilds commentedHi marc.groth,
I don't think you've misunderstood. I was just asking for an example feed to test this functionality with and in the past I'd used a feed from YouTube. I haven't used Feeds in years, so I'd forgotten that it can also be as simple as a CSV file. I'll create one and try that when I get the chance. I can also re-roll the patch to remove the outdated functions if no one else beats me to it. Thanks again.
Comment #14
guschilds commentedHi marc.groth,
I tested your patch. It worked and I committed it.
That said, it took me a while to realize that I had to map and provide both the URL and the ID in the feed. It seems like a feed would typically provide one or the other. For that reason, I added a
prepareValue()method to the plugin that takes one and generates the other. I've committed that separately, as well as the removal of the deprecated D7 functions mentioned above.Going to close this now. The committed code will be included in the next release.
Thanks for the patch! And thanks to MegaChriz for the assist!