Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: .:WindHack:. en 23 Abril 2011, 07:22 am



Título: [Python] SharkTube: ¡Descarga vídeos de YouTube!
Publicado por: .:WindHack:. en 23 Abril 2011, 07:22 am
(http://i55.tinypic.com/ou8pkh.png)

SharkTube es una utilidad o aplicación gratuita que te permite descargar vídeos de YouTube.
Citar
NOTA: Esta utilidad se encuentra registrada en SafeCreative (https://www.safecreative.org/work/1104239044305) bajo la licencia Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode).

Sus características y mejoras son:
  • Más servidores de YouTube.
       
  • Disponibilidad de formatos FLV, MP4, entre otros. *
       
  • Ejecutable por línea de comandos y alternativa con Interfaz web.
  • Mejor rendimiento en la búsqueda de servidores.
  • Extracción de título, descripción y enlace corto.
  • Posibilidad de compartir el vídeo en servicios sociales.

Shark.py
Código
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  4. #   Written by SebastiᮠCastaᯠ(.:WindHack:.)
  5. #             DaW - Labs & Cibernodo
  6. #   - www.daw-labs.com | | www.cibernodo.net  -
  7. #           Version: 1.1 ( Renaissance )
  8. #              Interactive Console
  9. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  10.  
  11. import urllib
  12. import re
  13.  
  14. bLogo = '''
  15. .--. .-.               .-.   .-----.    .-.
  16. : .--': :               : :.-.`-. .-'    : :
  17. `. `. : `-.  .--.  .--. : `'.'  : :.-..-.: `-.  .--.
  18. _`, :: .. :' .; ; : ..': . `.  : :: :; :' .; :' '_.'
  19. `.__.':_;:_;`.__,_;:_;  :_;:_;  :_;`.__.'`.__.'`.__.'
  20. (C) DaW - Labs & Cibernodo.
  21.  
  22. Welcome!
  23. NOTE: Enter -e or --end to exit the application.
  24.        '''
  25.  
  26. Char = ['%3A','%2F','%26','%2C','%3D','%252C','%253A','%7C','%3F']
  27. By =   [':','/','&',',','=',',',':','<begin>','?']
  28.  
  29.  
  30. def URLDecode(sURL):
  31.    for i in range(len(Char)):
  32.        sURL = sURL.replace(Char[i],By[i])
  33.    return sURL
  34.  
  35. def CleanData(sData,IsHTML=True):
  36.    if IsHTML == True:
  37.        rReg = re.compile(r'\&.*?;')
  38.    else:
  39.        rReg = re.compile(r',[0-9].?')
  40.    return rReg.sub('',sData)
  41.  
  42. def GetSourceCode(sURL):
  43.    try:
  44.        URL = urllib.urlopen(sURL)
  45.        sSource = URL.read()
  46.        URL.close()
  47.        return sSource
  48.    except:
  49.        print '[+] Connection error.'
  50.        exit()
  51.  
  52. def GetIndexVideo(sSource,Tags):
  53.    return sSource.find(Tags)
  54.  
  55. def GetVideoInformation(sSource):
  56.    sSource = sSource[2000:4500]
  57.    sInfo = []
  58.    #Title...
  59.    sReg = re.findall(r'<meta property="og:title" content="(.+)">',sSource)
  60.    sInfo.append(sReg[0])
  61.    #Shortlink...
  62.    sReg = re.findall(r'<link rel="shortlink" href="(.+)">',sSource)
  63.    sInfo.append(sReg[0])
  64.    #Description...
  65.    sReg = re.findall(r'<meta property="og:description" content="(.+)">',sSource)
  66.    sInfo.append(CleanData(sReg[0]))
  67.    return sInfo
  68.  
  69. def GetDownloadURL(sSource,sTitle):
  70.    sSource = sSource[10000:18000]
  71.    Begin = GetIndexVideo(sSource,'width="640" id="movie_player" height="390"    flashvars=')+57
  72.    sSource = sSource[Begin:]
  73.    End = GetIndexVideo(sSource,'allowscriptaccess="always" allowfullscreen="true"')+49
  74.    sSource = sSource[:End].split('<begin>')
  75.    lClean = []
  76.    sTitle = '&title='+sTitle.replace(' ','%20')+'%20[SharkTube]'
  77.    for i in sSource:
  78.        if i.startswith('http://v') and len(i) < 400:
  79.            lClean.append(CleanData(i,IsHTML=False)+sTitle)
  80.    return lClean
  81.  
  82. def __main__():
  83.    print bLogo
  84.    while 1:
  85.        Id = raw_input('Please, enter the YouTube Id. >> ')
  86.        if Id == '-e' or Id == '--end':
  87.            print 'Thank you for using SharkTube. Goodbye'
  88.            exit(1)
  89.        else:
  90.            if len(Id) == 11:
  91.                try:
  92.                    Source = URLDecode(GetSourceCode('http://www.youtube.com/watch?v='+Id))
  93.                    lInfo = GetVideoInformation(Source)
  94.                    URL = GetDownloadURL(Source,lInfo[0])
  95.                    print '''
  96.  
  97.            -*- Video Information -*-
  98.  
  99. Title: %s
  100. Shortlink: %s
  101. Description:
  102. %s
  103.  
  104. Link(s) available(s) to download:
  105. %s
  106.  
  107.          ''' % (lInfo[0],lInfo[1],lInfo[2],'\n\n'.join(URL))
  108.                except IndexError:
  109.                    print 'Wrong Id. Please, try again...'
  110.            else:
  111.                print 'The ID must be eleven characters. Try again...'
  112.  
  113. if __name__ == "__main__":
  114.   __main__()

Captura
(http://i51.tinypic.com/a9qq2q.png)

Para usar la versión de Interface Web ( Captura superior ) se debe de descargar el proyecto con todo lo necesario del siguiente enlace: http://db.tt/Jtq2sAA

Más información:
- DaW - Labs | SharkTube: ¡Descarga vídeos de YouTube! (http://daw-labs.com/sharktube-%C2%A1descarga-videos-de-youtube/)
- Cibernodo | SharkTube: ¡Descarga vídeos de YouTube! (http://foro.cibernodo.net/tema-sharktube-%C2%A1descarga-v%C3%ADdeos-de-youtube)

Eso es todo, espero les sea de ayuda y le puedan sacar provecho.
Por último, agradecimiento especial a 5475UK1 por la ayuda en el diseño y creación del logo.




Saludos.,


Título: ¡Descarga vídeos de YouTube!
Publicado por: angrisano en 22 Marzo 2014, 20:35 pm
Hola espero que os sirva a todos los que queráis bajar videos de Youtube.
Hay un programa que es muy sencillo y no tiene ningún problema en descargar los videos, música y todo lo que queráis de Youtube.
Este programa lo estoy usando ni me acuerdo ya. Y a mi siempre me ha ido de maravilla.
Se llama: YTD Video Downloader.
No os puedo mandar el enlace porque en este momento no lo encuentro. Un saludo y hasta pronto.