<b>Disclaimer:</b> This works in combination with a (free) third-party App Store app.
The code is here:
Using the gist downloader or manually saving it into Pythonista, it should be named 'YoutubeDL' when looking at your list of scripts in the Pythonista interface.
In the comments, you'll notice a bookmarklet:
The app that this script works in combination with is called 'iDownloads PLUS - Download Manager!', free, from Amad Marwat, in the iOS app store.
<b>How to use the script:</b>
Browse to http://m.youtube.com in Mobile Safari, view a video that you like (press Stop if it starts playing, you need to be looking at the page - not the video actually playing), then click on "Bookmarks" and select the bookmarklet that you created.
This will launch my script, which will pull the URL of the page you were looking at as an argument, parse it, figure out the direct download URL for the .mp4 video file, then open iDownloads directly to that URL to start downloading it.
I picked iDownloads because it's free, can download in the background (up to 10 minutes, with notifications when complete), can download multiple files, can play the .mp4 files directly, has HTTP sharing and iTunes documents capabilities (for getting the video to a computer), can save .mp4 files to your Photo roll, and also has 'Open In...' capabilities to move them to another app.
When the download opens in iDownloads, it'll prompt with a few options - I usually choose 'Download As' and then give it a whatever.mp4 video file name.
There's some tweaks, if you look at the source code of the script, where you can change what your preferred default download type / quality is (flv, mp4, webm, 720p, 480p, etc.).
<b>Why I wrote this:</b>
Apple has continued to crack down on App Store authors that make video download utilities and disallow submission / updates for apps that provide the ability to download content from YouTube and save it to your device. Every app that ever offered this feature (free or paid for) has always eventually removed it claiming 'compliance with YouTube Terms of Service', but it's always been Apple twisting the wrist.
With this bit of code, in theory you could use any app in the App Store as long as it provided a custom URL opener (in this case 'iDownloads://') and took web URLs and offered to download them if they were not web pages. This script should be 'future proof' against Apple :)
I use it in combination with a few other tools that I have so that, without accessing a computer, in my house I can download a YouTube video and then save it to a Samba / SMB file share on the network - making it instantly available to my TVs (WiiMC and XBMC on an AppleTV). Makes it a breeze to download stuff for my 3 year old without having to find the laptop.
It' did not work for me too. When the bookmark open pythonista at my iphone, pythonista wrote that the YoutubeDL.py has invalid syntax. Can you help me?
Remove the .py
Works fine! Thanks for creating the script, without .py ;-)
For all that were having problem with my script, I see there was a misunderstanding in my original instructions about this particular bit:
<i>Using the gist downloader or manually saving it into Pythonista, it should be named 'YoutubeDL.py'</i>
Every file listed in the Pythonista script list already has a '.py' suffix (behind the scenes), Pythonista just hides the suffix. I forget that many people new to python / Pythonista don't realize this, as I come to Pythonista from coding python in general on many different OSes. It wasn't a comment saying "When looking at your list of scripts in Pythonista, make sure it says 'YoutubeDL.py' ...". I was just trying to make sure you named it "YoutubeDL" - and just thought everyone understood the ".py" was a given.
Please forgive me for the confusion I've caused, it was a poor choice of comment on my part. I've edited the original for more clarity.
Also - are people using the current gist downloader(s) seeing the script appear in Pythonista with '.py' in the file name? Or were they following my poorly worded instructions and re-naming the file to include the '.py' ?
It's pretty clear from youtube's terms of service (http://www.youtube.com/static?gl=GB&template=terms) that this is not allowed
@DKatri - Not with my tool. I'm only downloading the media as offered up by YouTube. I'm not manipulating the media files, so I can't offer you a method for extracting the audio component of video+audio streams.
Works great with GoodReader, as noted by Dalorbi in this article: http://www.macstories.net/links/ios-youtube-downloader-with-pythonista/
Seems to download QUICKER than actually trying to watch it in YouTube. lol
I've made some minor modifications to the original script to better suit my workflow.
My rough hacked version is here:
It differs from the original in two ways. One rather than expecting the current web page to contain a YouTube video, it expects a URL to a page containing a YouTube video to be on the clipboard. This means that if you are browsing and come across a link to a YouTube containing page, you can simply copy the link and execute the script.
I make this easier by having a bookmark in the bookmark bar with this:
The other way my script varies is that it, somewhat crudely, presents a console alert to allow you to select one of your preferred video formats/qualities.
It's really just a clumsy hack of the original script (all credit to pudquick), but it is much better aligned to my workflow, where I don't want to have to load the actual YouTube page in order to grab a video.
Hopefully someone else may find it useful.
I'm ending up with a videoplayback.txt file instead of the .mp4. My guess is that Google changed scheme and broke this, can anyone confirm?
Still works for me
Thanks robertirish. I believe the key is to NOT have the official YouTube app installed. After deleting it the script works again for me.
Trying to get this to work with VLC since it has a download capabilities. The vlc:// will cause it to launch vlc, open the player like it's going to play the video, then it says Playback Failed and I'm left without the file. I don't really know what else to do with the vlc url scheme, as far as implementing it in the script goes, or if it even can for sure work. Trying to find some more documentation on VLCs url scheme. If anybody has a solution to work it with VLC though, that would be great. Or if anybody knows of other apps, besides iDownloads and GoodReader that it works with. I don't know how much experimenting you all have done with it. I wish I could use it with Documents, but Vittici's post about this said it didn't work and I've never found any info before about url schemes for Readdle apps.
https://forum.videolan.org/viewtopic.php?f=12&t=112372 is one month old from the VLC Lead Developer for IOS and Mac. It looks like vlc:// is only for remote files and streams but not for files that are already present in the VLC app for iOS.
Can you provide us the full URL that you are trying to use?
I was replacing iDownloads:// (I think that's what is originally used) in the script with vlc://, per instructions in a MacStories article about the script, the link for which I don't have on hand. But it is talking about using other apps like Documents or GoodReader. Though he mentions Documents doesn't seem to be able to download that. It says to replace the original scheme with, for the GoodReader example, ghttp:// . I despise GoodReader, but if necessary, I can just go with the one originally used in the script. Just thought it would be nice to be able to use VLC. But I guess I should have clarified that previously. Apologies and thanks for the response. Cheers!
This post is deleted!last edited by Inventurew
This post is deleted!last edited by