We should allow users to re-use YouTube videos in multiple places using the 'Web' media browser plugin rather than throwing an error saying the URL is already in the library.
This depends on #1121808: Change file_uri_to_object to re-use files by default and remove duplicate validation checks in handlers landing in Media first.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 1213184-remote-unnecessary-save-method.patch | 837 bytes | dave reid |
| #15 | media_youtube-reuse_existing_url-1213184-15.patch | 1.39 KB | ddyrr |
| #12 | youtubereuse.patch | 1.72 KB | ttjordan81 |
| #11 | reuse_existing-1213184-9.patch | 832 bytes | nikosnikos |
| #5 | 1213184-4.reuse-existing.patch | 1010 bytes | ksenzee |
Comments
Comment #1
dave reidComment #2
aaron commentedworks great!
Comment #3
aaron commentedand committed. thanks! btw, i added you as a maintainer to this module, Dave.
Comment #5
ksenzeeThis is broken for users of media 1.x, where file_uri_to_object() doesn't reuse existing file objects by default. I'm not sure if media_youtube is still willing to support media 1.x, but if so, here's a patch. Note that this patch also sets the file object's timestamp to the request time, so that when someone reuploads a video, it shows up as the newest media item at the top of the admin list.
Comment #6
mpotter commentedIn #5 you refer to "$file_obj->timestamp". Shouldn't this be "$file->timestamp" ??
Comment #7
aaron commentedgot that with mpotter's additional fix. Thanks guys.
Comment #8
nikosnikos commentedI know this is fixed but actually I think there's no need to override the
save()method in MediaInternetYouTubeHandler :file_save()function called just after that.save()method (fromMediaInternetHandler) call apreSave()method that have to be overriden in children to do additional operations, before the file has been savedMediaInternetYouTubeHandler :
MediaInternetHandler :
file_save :
Comment #9
aaron commentedGood points. However, file_save only adds a timestamp if not already present; we're actually potentially altering an already existing timestamp. But overriding ->presave would certainly simplify the code.
Comment #10
aaron commentedOh, whoops, I stand corrected. I missed your last snippet.
Comment #11
nikosnikos commented;) Here's a patch for #8
Comment #12
ttjordan81 commentedHere is the combination of the two patches... #1 and #5. Anyone still using alpha 5...
Comment #13
aaron commentedThis should be tested against both branches of the media module.
Comment #14
nikosnikos commentedActually ans as I said in #8 there's no need to override the save() method in MediaInternetYouTubeHandler
The patch in #11 should work and allow to reuse youtube videos without overriding save() method.
Comment #15
ddyrr commentedfor alpha5, according to #14
Comment #16
dave reidOk so I think this is what needs to be committed to 7.x-1.x still. Will test manually today.
Comment #17
dave reidTested and committed #16 to Git: http://drupalcode.org/project/media_youtube.git/commit/989be74