Síguenos en Facebook


Síguenos en Twitter

Compartir este tema:
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Aplicación para la descarga de archivos de música desde internet.

Nombre: Metáfora Music Downloader.

Version: 2.0.

Autor: Fernando Gómez (Sifaw).

Sistemas Operativos: Multiplataforma. Programado bajo MacOSX por lo que en los demás sistemas puede tener fallos estéticos.

Lenguaje: Python 2.5.4.

Licencia: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0.

Fecha de lanzamiento: 22/08/10.

Idioma: Español.

Capturas:

Video:

Código:

#importamos los modulos
 
 
#! /usr/bin/python
import wx
import thread
import urllib as u
 
class Busqueda(wx.Panel):
    def __init__(self, panel):
        #Colocamos los botones
        wx.Panel.__init__(self, panel)
        self.search = wx.SearchCtrl(self, size=(300, -1), style=wx.TE_PROCESS_ENTER)
        self.search.ShowCancelButton(True)
        npag = wx.StaticText(self, label='N de paginas')
        self.pag = wx.SearchCtrl(self, size=(50, -1), style=wx.TE_PROCESS_ENTER)
        self.pag.SetValue('0')
        self.pag.ShowSearchButton(False)
        canc = wx.StaticBox(self, label='Lista de canciones', size=(290, 225))
        self.lista = wx.ListBox(self, size=(280, 215), style=wx.LB_SINGLE)
        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.search, 0, wx.ALL|wx.EXPAND, 3)
        middlesizer = wx.BoxSizer(wx.HORIZONTAL)
        middlesizer.Add(npag, 0, wx.ALL, 3)
        middlesizer.Add(self.pag, 0, wx.ALL, 3)
        footsizer = wx.StaticBoxSizer(canc, wx.VERTICAL)
        footsizer.Add(self.lista, 0, wx.ALL, 0)
        totalsizer = wx.BoxSizer(wx.VERTICAL)
        totalsizer.Add(topsizer, 0, wx.ALL|wx.EXPAND, 3)
        totalsizer.Add(middlesizer, 0, wx.ALL|wx.ALIGN_RIGHT, 3)
        totalsizer.Add(footsizer, 0, wx.ALL, 3)
        self.SetSizer(totalsizer)
        totalsizer.Fit(self)
        self.lista.Bind(wx.EVT_LEFT_DCLICK, self.eleccion)
        self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.cancelbusca, self.search)
        self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.cargar, self.search)
        self.Bind(wx.EVT_TEXT_ENTER, self.cargar, self.search)
 
    def cancelbusca(self, event):
        self.search.SetValue('')
 
    def eleccion(self, event):
        pg2.listdesc.Append(self.lista.GetString(self.lista.GetSelection()), self.lista.GetClientData(self.lista.GetSelection()))
 
    def cargar(self, event):
        #Nos conectamos a goear y realizamos la busqueda selccionada mostrandolo en el listbox
        pag = int(self.pag.GetValue())
        busqueda = ''
        for i in self.search.GetValue():
            if i == ' ':
                busqueda += '+'
            else:
                busqueda += i
        self.lista.Clear()
        n = 0
        while n <= pag:
            web = u.urlopen('http://www.goear.com/search.php?q=%s&p=%i' % (busqueda, n))
            web = web.read()
            i = web.find('Escuchar')
            fin = False
            url = False
            canciones = []
            lugar = []
            but = ''
            can = 0
            while fin != True:
                while web[i:i+8] != 'Escuchar':
                    i += 1
                while url == False:
                    i += 1
                    if (web[i] == '"') and (web[i+1] == 'l'):
                        url = True
                i += 1
                while web[i] != '"':
                    but += web[i]
                    i += 1
                lugar.append(but)
                but = ''
                while web[i] != '>':
                    i += 1
                i += 1
                while web[i] != '<':
                    but += web[i]
                    i += 1
                canciones.append(but)
                self.lista.Append(canciones[0], lugar[0])
                but = ''
                canciones = []
                lugar = []
                url = False
                can += 1
                if can == 10:
                    fin = True
            n += 1
 
class Descarga(wx.Panel):
    def __init__(self, panel):
        wx.Panel.__init__(self, panel)
        self.descact = False
        self.barra = wx.Gauge(self, -1, size=(297, -1))
        self.descbtn = wx.Button(self, -1, 'Descargar')
        dsc = wx.StaticBox(self, label='Lista de descarga', pos=(5, 55), size=(290, 240))
        self.listdesc = wx.ListBox(self, pos=(10, 75), size=(280, 221), style=wx.LB_SINGLE)
        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.barra, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 3)
        middle = wx.BoxSizer(wx.HORIZONTAL)
        mid = wx.BoxSizer(wx.HORIZONTAL)
        mid.Add(wx.StaticLine(self, -1, size=(97, -1)), 0, wx.ALL|wx.EXPAND, 3)
        mid.Add(self.descbtn, 0, wx.ALL, 3)
        mid.Add(wx.StaticLine(self, -1, size=(97, -1)), 0, wx.ALL|wx.EXPAND, 3)
        foot = wx.StaticBoxSizer(dsc, wx.HORIZONTAL)
        foot.Add(self.listdesc, 0, wx.ALL, 0)
        total = wx.BoxSizer(wx.VERTICAL)
        total.Add(topsizer, 0, wx.ALL, 3)
        total.Add(middle, 0, wx.ALL, 3)
        total.Add(mid, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 3)        
        total.Add(foot, 0, wx.ALL, 3)
        self.SetSizer(total)
        total.Fit(self)
        self.listdesc.Bind(wx.EVT_LEFT_DCLICK, self.eliminarlist)
        self.Bind(wx.EVT_BUTTON, self.activardesc, self.descbtn)
 
    def activardesc(self, event):
        if self.descbtn.Label == 'Descargar':
            thread.start_new_thread(self.descargar, ())
            self.descact = True
            self.descbtn.Label = 'Cancelar'
        else:
            self.descact = False
            self.descbtn.Label = 'Descargar'
 
    def descargar(self):
        #Buscamos el link de descarga y descargamos la eleccion escogida
        while self.descact:
            try:
                self.barra.Pulse()
                web = u.urlopen('http://www.videofindr.net/goear/?url=http://goear.com/%s' % self.listdesc.GetClientData(0))
                web = web.read()
                tam = len(web)
                i = web.find('http:')
                url = ''
                while web[i] != '"':
                    url += web[i]
                    i += 1
                u.urlretrieve(url, "%s.mp3" % self.listdesc.GetString(0), reporthook=self.progresodesc)
                self.listdesc.Delete(0)
                self.barra.SetRange(0)
                self.barra.SetValue(0)
            except:
                self.barra.SetRange(0)
                self.barra.SetValue(0)
                self.descact = False
                self.descbtn.Label = 'Descargar'
 
    def progresodesc(self, bloque, tamano, total):
        self.barra.SetRange(total)
        totaldesc = bloque * tamano
        self.barra.SetValue(totaldesc)
 
    def eliminarlist(self, event):
        try:
            self.listdesc.Delete(self.listdesc.GetSelection())
        except:
            pass
 
class Frame(wx.Frame):
    def __init__(self):
        #Frame en el que se veran los widgets a partir de dos pestanas
        wx.Frame.__init__(self, None, -1, title="Metafora Music Downloader", pos=wx.DefaultPosition, 
            size=(315, 390), 
            style=wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER|wx. MAXIMIZE_BOX))
        panel = wx.Panel(self)
        nb = wx.Notebook(panel)
        pg1 = Busqueda(nb)
        global pg2
        pg2 = Descarga(nb)
        nb.AddPage(pg1, "Busqueda")
        nb.AddPage(pg2, "Descarga")
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(nb, 1, wx.EXPAND)
        panel.SetSizer(sizer)
        self.SetExtraStyle(wx.FRAME_EX_METAL)
        self.Center()
 
class App(wx.App):
    def OnInit(self):
        frame = Frame()
        frame.Show()
        self.SetTopWindow(frame)
        return True
 
if __name__ == '__main__':
    app = App()
 
 
 app.MainLoop()

Deja una respuesta

Tu debes estar Loggueado para comentar