After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 488827 - Save/Share YouTube videos
Save/Share YouTube videos
Status: RESOLVED DUPLICATE of bug 350261
Product: totem
Classification: Core
Component: YouTube plugin
2.20.x
Other Linux
: Normal normal
: ---
Assigned To: General Totem maintainer(s)
General Totem maintainer(s)
: 518711 525105 539883 (view as bug list)
Depends on: 542663
Blocks:
 
 
Reported: 2007-10-21 15:46 UTC by Michael Monreal
Modified: 2009-11-04 23:03 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
Add ability to save a video on localy (2.79 KB, patch)
2008-08-09 01:47 UTC, Eric Piel
none Details | Review
Permit to save a video locally - update with correct default directory (3.27 KB, patch)
2008-08-09 20:59 UTC, Eric Piel
needs-work Details | Review
Add "save as" for youtube videos (3.44 KB, patch)
2008-12-08 14:41 UTC, Eric Piel
needs-work Details | Review
Add "save as" for youtube videos (3.98 KB, patch)
2008-12-24 21:46 UTC, Eric Piel
needs-work Details | Review

Description Michael Monreal 2007-10-21 15:46:58 UTC
It would be very nice if Totem would let the user save YouTube videos to disc. this could be implemented in a right-click context menu on the thumb images. This context menu could also hold a "Play" entry or "Send link to a friend"
Comment 1 Philip Withnall 2007-10-21 17:38:02 UTC
Also a nice idea.
Comment 2 Björn Martensen 2008-02-14 19:36:01 UTC
yeah, saving them would be cool.
Comment 3 Philip Withnall 2008-02-25 22:11:32 UTC
*** Bug 518711 has been marked as a duplicate of this bug. ***
Comment 4 Jakub 'Livio' Rusinek 2008-03-30 11:26:41 UTC
ping.

maybe an option in plugins configuration, to automatically save them somewhere (and/or cache) when double clicking?
Comment 5 Jakub 'Livio' Rusinek 2008-03-30 11:28:36 UTC
and drag'n'drop from results into desktop/directory...
Comment 6 Philip Withnall 2008-03-30 11:33:09 UTC
I haven't had a chance to do any work on this, but I don't think automatically saving them's a good idea. Saving on drag'n'drop is good.

Note to self: see how this fits in with Wim's work on seeking YouTube videos.
Comment 7 Philip Withnall 2008-03-30 11:45:50 UTC
*** Bug 525105 has been marked as a duplicate of this bug. ***
Comment 8 Jakub 'Livio' Rusinek 2008-03-30 12:16:10 UTC
> I don't think automatically saving them's a good idea

Of course I mean downloading of results added to the playlist, not all results ;) .
Comment 9 Jakub 'Livio' Rusinek 2008-04-10 18:33:34 UTC
I have another approach for what I want. When adding YT videos to playlist, they shouldn't be autoplayed, but buffered with little progressbar on playlist shown.

It's good for new feature request, since I made little off topic here.
Comment 10 Jakub 'Livio' Rusinek 2008-04-10 18:36:13 UTC
Submitted: bug 527395.

PS: I'm silent beginning from now. EOOT (EndOfOffTopic)
Comment 11 Philip Withnall 2008-06-24 06:35:49 UTC
*** Bug 539883 has been marked as a duplicate of this bug. ***
Comment 12 Eric Piel 2008-08-09 01:47:37 UTC
Created attachment 116199 [details] [review]
Add ability to save a video on localy

Here is a patch for implementing this feature. It adds a fourth option in the context menu called "Save as...".
By default the filename is the title of the video. In case the user select a file already existing, a confirmation dialog is displayed.

I think this is usable as it. However, I can see two possible improvement points:
* do the file retrieving in a background thread. I haven't found a way to keep the (python) thread running while no gtk event is occuring, and using idle_add() leads to 100% cpu usage. 
* by default propose to save in the "Video" directory (but I don't know how to do this independently of distro and locale)
Comment 13 Jakub 'Livio' Rusinek 2008-08-09 08:54:48 UTC
Would be great to see this upstream.

> * by default propose to save in the "Video" directory (but I don't know how to
do this independently of distro and locale)

Read about XDG and bindings (pyxdg?).
Comment 14 Eric Piel 2008-08-09 20:59:43 UTC
Created attachment 116265 [details] [review]
Permit to save a video locally - update with correct default directory

This is an updated version of the patch, which display the file chooser by default in the same directory as the user last time opened a file. 

Jakub, thank you for the tip. Indeed XDG Base Directory Specification should give the correct info about the Video directory. Eventually, I found the "open_path" gconf key. It should fit even better the user, and this avoids to add a new dependency on totem :-)
Comment 15 Bastien Nocera 2008-08-10 12:46:10 UTC
The problem with this implementation is that it would conflict with playbin2's ability to create on-disk caches. I'll make this bug dependent on playbin2 for now, and see if we can generalise the saving of remote videos.
Comment 16 Eric Piel 2008-08-10 13:13:21 UTC
Hi Bastien, could explain more in what it would conflict with playbin2? This implementation simply download the file independently from what is happening in totem. While downloading a video, I can watch the same video or another video without any problem. I couldn't find much info about playbin2, and I can't find a reason why it would conflict with the implementation...

Once playbin2 is used by totem, we could make the implementation more clever and re-used on the on-disk cache instead of re-downloading the video. But that's only an enhancement.
Comment 17 Bastien Nocera 2008-12-05 16:11:31 UTC
Playbin2 can use an on-disk cache to provide YouTube style buffering for streams. So after playing the file back once, the full video would be available on the disk, saving it would be a matter of copying the buffer onto a new location.

I'd be happy to commit your patch as long as you made it more separate from the rest of the code so it can easily be ripped out when we get playbin2 support. Adding a few comments about that fact in the sources would also help.
Comment 18 Eric Piel 2008-12-08 14:41:55 UTC
Created attachment 124173 [details] [review]
Add "save as" for youtube videos

Here is an update of the patch. It's against latest svn revision.

In case of playbin2, the GUI part (menu + file-browser would stay as is), while the rest would be modified. I've added explicit comments about it in this later part.
Comment 19 Bastien Nocera 2008-12-08 15:09:50 UTC
Two problems I can see with that patch:
- We should also show the "Save as..." menu item in the Movie top-level menu, but only when playing videos from YouTube.
- I believe that we have a little problem with the video list widget, where the UI is shared, so adding a menu item to /ui/totem-video-list-popup would show it in all the plugins that use it (say MythTV or tracker). Am I wrong there?
- The progress should be a modal dialogue (so we can only download one stream at a time), and be cancellable.
Comment 20 Eric Piel 2008-12-08 16:23:07 UTC
(In reply to comment #19)
> Two problems I can see with that patch:
> - We should also show the "Save as..." menu item in the Movie top-level menu,
> but only when playing videos from YouTube.
I can have a try at it, but I don't know much about how to control the main menu, so it might take some time. That said, I think it can be implemented later on, and doesn't need to be present to add the feature to totem.

> - I believe that we have a little problem with the video list widget, where the
> UI is shared, so adding a menu item to /ui/totem-video-list-popup would show it
> in all the plugins that use it (say MythTV or tracker). Am I wrong there?
You probably know much more than me about this! I couldn't test the two other plugins you've cited. However, /ui/totem-video-list-popup is already used by the youtube plugin for "Opening in a browser", so I guess it's rather easy to check (and if there is a problem, it already exists).

> - The progress should be a modal dialogue (so we can only download one stream
> at a time), and be cancellable.
Yes, that's probably really the main problem in the current implementation. To fix it perfectly, it would require a complete implementation of a downloader (à la Firefox). I wish there could be a generic downloader utility in gnome, to which every applications could delegate all this work. Now, i'm not convinced by the modal dialogue because it would completely prevent the use of totem while downloading. What I can try to do is to disable the widgets of the youtube plugin while the downloading is in progress.

Comment 21 Philip Withnall 2008-12-08 16:40:03 UTC
(In reply to comment #20)
> You probably know much more than me about this! I couldn't test the two other
> plugins you've cited. However, /ui/totem-video-list-popup is already used by
> the youtube plugin for "Opening in a browser", so I guess it's rather easy to
> check (and if there is a problem, it already exists).

The UI common to all TotemVideoLists is in data/video-list.ui, and doesn't include the "Open in Web Browser" entry, which is added in youtube.py:149. That's what you should do.
Comment 22 Eric Piel 2008-12-08 16:50:11 UTC
(In reply to comment #21)
> The UI common to all TotemVideoLists is in data/video-list.ui, and doesn't
> include the "Open in Web Browser" entry, which is added in youtube.py:149.
> That's what you should do.
Ah, great! "Save as" is added to the menu in exactly the same way as "Open in Web Browser" so with respect to this point, it should work fine :-)

Comment 23 Eric Piel 2008-12-24 21:46:28 UTC
Created attachment 125282 [details] [review]
Add "save as" for youtube videos

Here is a new version of the patch which disable the usage of the plugin while the video is downloading. It also handles exceptions while downloading, so that network errors don't block the plugin.
Comment 24 Philip Withnall 2008-12-28 17:41:39 UTC
+		action = gtk.Action ("save-as", _("_Save as..."), _("Save the video locally"), "gtk-save-as")

The action's text should be "Save As..." (note the capitalisation).

+ 		dialog = gtk.FileChooserDialog(title=_("Save as"),

Similarly, the title should be "Save As...". Can you add spaces to the parameter initialisation too please? (e.g. "title = _(")

Also, there should be spaces after function names and before the opening bracket, for stylistic consistency. (e.g. "gtk.FileChooserDialog (")

+ 		while gtk.events_pending():
+ 			gtk.main_iteration()

You might want to add a comment (either here or above where you complain about threads in PyGTK :)) about this running in the main loop and manually dispatching pending events every so often. I'm not sure this is really the best way to do things, but it can be changed once this has been committed if it turns out to not perform well enough in real usage.

You might want to update the /apps/totem/open_path GConf key once a save location's been chosen.

To address the remaining issues from comment #19:
* You can use totem.get_ui_manager to get the GtkUIManager for the main window, which should allow you to add the Save As action to the main menu. Don't forget to remove it when the plugin's deactivated, or when the currently-playing URI is changed to a non-YouTube video.
* You should be able to cancel the download by throwing an exception in download_report_cb, then catching it in on_save_as_activated. This would mean redesigning the UI, though, so I'd be OK with this being done later, especially since it might be a good idea to add cancel functionality to the entire plugin (i.e. be able to cancel searches themselves) anyway.

Other than that, the patch looks good to me. Thanks for spending the time on this. :)
Comment 25 Bastien Nocera 2009-11-04 19:55:39 UTC
Now that we have on-disk buffering for QuickTime and FLV streams, this feature wouldn't be any different from saving the stream that's currently playing back.

*** This bug has been marked as a duplicate of bug 350261 ***
Comment 26 Eric Piel 2009-11-04 23:03:06 UTC
But can you save the same way a video which is not being played but only displayed in the playlist (as search result or related video)?