Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

YouTube MP4 download & convert video to MP3


  • Please log in to reply
152 replies to this topic
flashkid
  • Members
  • 115 posts
  • Last active: Apr 12 2013 06:33 PM
  • Joined: 25 Aug 2007
Hi guys.
I just wanted to share my code with you. As I like functions more than Gosub Labels or just the complete code in my main file, I have created this functions:
*see below
This could easily be improved by splitting up the functions even more to return just the html file, so it can be used for getting the title and the download links and does not have to be downloaded again.
Another function which might be useful would be to return the list of all available fmt values for this video with their corresponding urls, so you can easily parse them.

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Is this complete code to download YT, cuz it didn't work with my AHK basic? :?:

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
I just tried to download some YTs but I get error messages: URL not found! :shock: It seems YT has done something to prevent download using this script? :?: I tried several URLs ... Can someone confirm this? :?:

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
hi bruno,
added this, works now
gosub,titlesearch       ;-- >>>>>>>>>>
;msgbox,Title=%title%`nVideoid=%videoid%`nUsername=%username%

stringreplace,hss,hss,%xx2%,,all           ;-- "fmt_url_map":
stringreplace,hss,hss,",,all
stringreplace,hss,hss,%s%,,all
stringreplace,hss,hss,\/,/,all
stringreplace,hss,hss,\,&,all
stringreplace,hss,hss,u0026,,all


.. but I think I'm not able always to run script

free mozilla firefox addon
<!-- m -->http://www.downloadh...r.net/index.php<!-- m -->
<!-- m -->http://www.downloadh... ... conversion<!-- m -->

Freeware:
<!-- m -->http://www.dvdvideos... ... wnload.htm<!-- m -->

--------------------
@flashkid
thank you for the function
I didn't realized to remove all special characters in title yet
didn't understand how to use the function >> YTDownloadURL(URL,fmt)

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks, garry! Added in the following location, but didn't work! :shock:

stringreplace,hss,hss,%xx2%,,all           ;-- "fmt_url_map":
stringreplace,hss,hss,",,all
stringreplace,hss,hss,%s%,,all
stringreplace,hss,hss,\,,all
; Added on 032511.
stringreplace,hss,hss,\/,/,all
stringreplace,hss,hss,\,&,all
stringreplace,hss,hss,u0026,,all


bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
I am also not very excited about downloading these huge downloaders (15MB +). :shock: Your script was small and perfect for my intended uses. :lol:

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
sorry bruno, forget to mention , one line removed , see above again
( if you copy the script at first page should also work )

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks! Now it works!! :lol:

flashkid
  • Members
  • 115 posts
  • Last active: Apr 12 2013 06:33 PM
  • Joined: 25 Aug 2007
I updated my function as well.
This is a working example of downloading a youtube video: *see below

@garry:
What didn't you understand?

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
thank you flashkid for the very small script, works fine !
httpquery.ahk :
<!-- m -->http://www.autohotke... ... highlight=<!-- m -->

I didn't understand how to use function and how really works ( I'm working with gwbasic -style ... grrr )
maybe just missing how to select available quality (fmt)
usually I download best quality ( but not HD ( fmt=37) , video not runs well with my netbook )

flashkid
  • Members
  • 115 posts
  • Last active: Apr 12 2013 06:33 PM
  • Joined: 25 Aug 2007
I don't like labels, I put everything possible into functions, because the variables are only known to the functions until you declare them as global. This is a big improvement if you write very long scripts with many variables.
It would be easy to write a function that extracts all available qualities and returns them in a pipe-delimited list or something similar, maybe I will do this tomorrow.
I do not use the script personally, just wrote this for some friends who want to get the audio tracks from youtube.

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
@flashkid

... just wrote this for some friends ...

thank you flashkid ...

flashkid
  • Members
  • 115 posts
  • Last active: Apr 12 2013 06:33 PM
  • Joined: 25 Aug 2007
It's me again. I have rewritten my functions to be a complete "Youtube library".
Have a look: YTLib.ahk
Example #1: Download a file with a given quality
Example #2: Download all possible qualities with correct file extensions

There is also a documentation available: YTLib Documentation

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
I presume you need AHK_L for flashkid's script? :?: :lol:

flashkid
  • Members
  • 115 posts
  • Last active: Apr 12 2013 06:33 PM
  • Joined: 25 Aug 2007
No, AHK Basic ;)