API YOUTUBE MP3

Esta sección es para compartir scripts, librerías y herramientas.

Moderator: Flipeador

luisa
Posts: 1
Joined: 22 Jan 2018, 14:10
Contact:

API YOUTUBE MP3

13 Mar 2018, 19:58

Les comparto esta API para colocar un botón para descargar musica en sus sitios web.
El sitio web es https://www.convertmp3.io/

Esta es la breve porción de código HTML que le permite agregarlo a su sitio.
No olvides cambiar los valores ( enlace de YouTube , ancho y alto ) antes de colocarlo en tu página.

HTML:
<iframe style = "width: 230px; height: 60px; border: 0; overflow: hidden;" scrolling = "no" src = "// http://www.convertmp3.io/widget/button/?video= https://www.youtube.com/watch?v=i62Zjga8JOM" & color = c91818 >
garry
Posts: 3760
Joined: 22 Dec 2013, 12:50

Re: API YOUTUBE MP3

14 Mar 2018, 03:20

gracias , saved as > convertYT2MP3.hta and run

Code: Select all

<iframe style = "width: 230px; height: 60px; border: 0; overflow: hidden;" scrolling = "no" src = "http://www.convertmp3.io/widget/button/?video= https://www.youtube.com/watch?v=i62Zjga8JOM" & color = c91818 >
OnClipboardChange
copy youtube url > get convertmp3 button to download MP3

Code: Select all

;- copy youtube url > get convertmp3 button to download MP3 
#persistent
#NoEnv
SendMode,Input
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode, 2
SetBatchLines, -1
Filename1   =YT2MP3
filehta=%a_scriptdir%\yt2mp3.hta
url=
clipboard=
IfWinNotExist,YouTube
   run,https://www.youtube.com/watch?v=l_8e-3bbChc
return

OnClipboardChange:
If (A_EventInfo=1)
{
url = %Clipboard%
stringmid,url,url,1,200
ifinstring, url, www.youtube.com
  {
  filedelete,%filehta%
  StringGetPos, pos, url, &
  if (pos>=2)
    StringLeft, url, url, pos
  ifnotexist,%filehta%
     {
     fileappend,<iframe style = "width: 230px; height: 60px; border: 0; overflow: hidden;" scrolling = "no" src = "http://www.convertmp3.io/widget/button/?video= %url%" & color = c91818 >,%filehta%
     run,%filehta%
     }
  }
}
return
esc::exitapp
FranciscoVillalba
Posts: 1
Joined: 20 Aug 2020, 11:45

Re: API YOUTUBE MP3

20 Aug 2020, 16:24

Hola a todos

Existen varias formas de descargar videos y música de YouTube. Desde convertidores Web, hasta APIs

Algunos se enlistan en el sitio BitCuco

Saludos!
garry
Posts: 3760
Joined: 22 Dec 2013, 12:50

Re: API YOUTUBE MP3

21 Aug 2020, 05:09

example to download youtube as mp4

see > https://youtube-dl.org/ for MP4 / and also ffmpeg for MP3

Code: Select all

/*
MODIFIED =20190526
CREATED  =20190526
download Youtube MP4
https://youtube-dl.org/
*/

#warn
#persistent
#singleinstance,force
;#IfWinActive YouTube
setworkingdir,%a_scriptdir%
settitlematchmode,2
clipboard=

fdpro:=a_scriptdir . "\YT_programs"
fdmp4:="D:\M_MEDIA\M_VIDEO"
;fdmp4:="D:\M_MEDIA\M_FILME\Hitchcock_Hour_MP4"

ifnotexist,%fdpro%
  filecreatedir,%fdpro%
ifnotexist,%fdmp4%
  filecreatedir,%fdmp4%

;- ffmpeg needed for only MP3-file  
;- in same directory then youtube-dl.exe
;- without ffmpeg is always MP4 / with ffmpeg can be MP4 with better quality or also xy.webm or xy.mkv 
youtubedl:=fdpro . "\youtube-dl.exe"
ifexist,%youtubedl%
{
loop,%youtubedl%        
   SP1:=A_loopFileShortPath
RunWait, %comspec% /k %sp1% -U                    ;- Update youtube-dl.exe
}
else
  run,https://youtube-dl.org/latest/youtube-dl.exe
return
;--------------
esc::exitapp
;--------------

OnClipboardChange:
{
id:=""
L:=""
If (A_EventInfo=1)
 {
if (winactive("YouTube"))
  {
 if (instr(clipboard, "https://www.youtube.com"))
    {
    Loop,parse,clipboard, `n, `r
       {
     x= %a_loopfield%
     if x=
     continue
        Loop, Parse,x,`/`=`&`?%a_space%`#`:  
          {
          id:= A_LoopField
          stringlen,L,id
          if (L=11)
            break
          }
       }
    }
  }
if (L=11)
    {
    clipboard=
    url=https://www.youtube.com/watch?v=%id%
    ; without ffmpeg is always MP4 / with ffmpeg can be MP4 with better quality or als webm or mkv 
    ifexist,%youtubedl%
      {
      ;RunWait, %comspec% /k %sp1% %url% -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
      ;- create xy.vtt file if subtitle exist with original language
      RunWait, %comspec% /k %sp1% %url% --verbose --youtube-skip-dash-manifest --write-auto-sub --sub-lang de -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
      ;RunWait, %comspec% /k %sp1% %url% --verbose --youtube-skip-dash-manifest --write-auto-sub --all-subs -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"

      ;RunWait, %comspec% /k %sp1% %url% --verbose --youtube-skip-dash-manifest --write-auto-sub -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
      ;RunWait, %comspec% /k %sp1% %url% --youtube-skip-dash-manifest --restrict-filenames -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s"
      }
    url=
    id=
    ;run,%fdmp4%
    }
 }
return
}
;--------------

example to download youtube as mp3 / ffmpeg needed for MP3-file

Code: Select all

/*
MODIFIED =20190526
CREATED  =20190526
download Youtube MP3
https://youtube-dl.org/
*/

#warn
#persistent
#singleinstance,force
;#IfWinActive YouTube
setworkingdir,%a_scriptdir%
settitlematchmode,2
clipboard=

fdpro:=a_scriptdir . "\YT_programs"
fdmp3:="D:\M_MEDIA\M_MUSIC"

ifnotexist,%fdpro%
  filecreatedir,%fdpro%
ifnotexist,%fdmp3%
  filecreatedir,%fdmp3%
youtubedl:=fdpro . "\youtube-dl.exe"
ifexist,%youtubedl%
{
loop,%youtubedl%        
   SP1:=A_loopFileShortPath
RunWait, %comspec% /k %sp1% -U                    ;- Update youtube-dl.exe
}
else
  run,https://youtube-dl.org/latest/youtube-dl.exe
return
;--------------
esc::exitapp
;--------------

OnClipboardChange:
{
id:=""
L:=""
If (A_EventInfo=1)
 {
;if (winactive("YouTube"))
  {
 if (instr(clipboard, "https://www.youtube.com") or (instr(clipboard,"https://invidio.us") ) )
    {
    Loop,parse,clipboard, `n, `r
       {
     x= %a_loopfield%
     if x=
     continue
        Loop, Parse,x,`/`=`&`?%a_space%`#`:  
          {
          id:= A_LoopField
          stringlen,L,id
          if (L=11)
            break
          }
       }
    }
  }
if (L=11)
    {
    clipboard=
    url=https://www.youtube.com/watch?v=%id%
    ifexist,%youtubedl%
      {
      ;RunWait, %comspec% /k %sp1% %url% -x --audio-format mp3 --audio-quality 192k --youtube-skip-dash-manifest --restrict-filenames -o "%fdmp3%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s" ;- needs ffmpeg.exe
      RunWait, %comspec% /k %sp1% %url% -x --audio-format mp3 --audio-quality 192k --youtube-skip-dash-manifest -o "%fdmp3%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s" ;- needs ffmpeg.exe
      }
    url=
    id=
    run,%fdmp3%
    }
 }
return
}
;--------------

/*
https://youtube-dl.org/

ffmpeg for AUDIO :
https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip
https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip
https://ffmpeg.zeranoe.com/builds/win32/static/
http://ffmpeg.org/download.html#build-windows

-f, --format FORMAT              Video format code, see the "FORMAT
                                     SELECTION" for all the info
    --all-formats                    Download all available video formats
    --prefer-free-formats            Prefer free video formats unless a specific
                                     one is requested
    -F, --list-formats               List all available formats of requested
                                     videos
    --youtube-skip-dash-manifest     Do not download the DASH manifests and
                                     related data on YouTube videos
    --merge-output-format FORMAT     If a merge is required (e.g.
                                     bestvideo+bestaudio), output to given
                                     container format. One of mkv, mp4, ogg,
                                     webm, flv. Ignored if no merge is required


	if instr(address, "youtube")
	  ;~ runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" -f 18 --write-auto-sub --sub-lang fr -- %address% > temp.txt,, Hide, pid
	  ;~ runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" -f 18 --write-auto-sub --sub-lang en -- %address% > temp.txt,, Hide, pid
	  runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" --write-auto-sub --sub-lang en -- %address% > temp.txt,, Hide, pid
	else
	  runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" --all-subs -- %address% > temp.txt,, Hide, pid


*/
;=================================== END script MP3 - Download ==============


Return to “Scripts y Funciones”

Who is online

Users browsing this forum: No registered users and 15 guests