Beispiel #1
0
    def handle(self):
        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).strip()
        self.url = [l for l in self.data.split('\n')
                    if l.startswith('qvod:')][0]
        self.status = 'invalid'
        print self.url
        if valid_url(self.url):
            self.status = 'ok'
        else:
            return

        # send back a HTTP header to tell the javascript the status
        self.response = 'HTTP/1.0 200 OK\r\n' + \
                        'Server: OneFile 1.0\r\n' + \
                        'Content-length: ' + str(len(self.status)) + '\r\n' + \
                        'Content-type: text/plain\r\n\r\n' + \
                        self.status
        self.request.sendall(self.response)
        # Put the received URL into queue
        if self.status == 'ok':
            if _URL_QUEUE_:
                _URL_QUEUE_.put(self.url)
            else:
                print self.url
Beispiel #2
0
 def OnAddTask(self, e):
     url = self.tc_url.GetValue()
     trunks = downloader.valid_url(url)
     if not trunks:
         self._Alert("Invalid URL!")
     elif url in [t[1] for t in self.jobs_info]:
         self._Alert("You have already added an identical URL!")
     else:
         self.filename = trunks[2]
         dlg_filename = FileNameDialog(None, "Video name", self.filename)
         dlg_filename.ShowModal()
         self.filename = dlg_filename.string
         dlg_filename.Destroy()
         self.jobs_info.append((-1, url, Queue.Queue(0)))  # Create a new queue for this thread
         self.lc_dv._AddItem(self.filename)  # Add a task with the video name
Beispiel #3
0
 def OnAddTask(self, e):
     url = self.tc_url.GetValue()
     trunks = downloader.valid_url(url)
     if not trunks:
         self._Alert('Invalid URL!')
     elif url in [t[1] for t in self.jobs_info]:
         self._Alert('You have already added an identical URL!')
     else:
         self.filename = trunks[2]
         dlg_filename = FileNameDialog(None, 'Video name', self.filename)
         dlg_filename.ShowModal()
         self.filename = dlg_filename.string
         dlg_filename.Destroy()
         self.jobs_info.append(
             (-1, url,
              Queue.Queue(0)))  # Create a new queue for this thread
         self.lc_dv._AddItem(
             self.filename)  # Add a task with the video name
Beispiel #4
0
 def handle(self):
     # self.request is the TCP socket connected to the client
     self.data = self.request.recv(1024).strip()
     self.url, = [l.replace('data=', 'qvod://') for l in self.data.split('\n') if l.startswith('data=')]
     self.status = 'invalid'
     if valid_url(self.url):
         self.status = 'ok'
     elif self.url in _added_urls_:
         self.status = 'have'
     # just send back a HTTP header to tell the javascript the status
     self.response = 'HTTP/1.0 200 OK\r\n' + \
                     'Server: OneFile 1.0\r\n' + \
                     'Content-length: ' + str(len(self.status)) + '\r\n' + \
                     'Content-type: text/plain\r\n\r\n' + \
                     self.status
     self.request.sendall(self.response)
     # Put the received URL into queue
     if self.status == 'ok':
         if _URL_QUEUE_:
             _URL_QUEUE_.put(self.url)
         else:
             print self.url
Beispiel #5
0

#class qvodDownload(threading.Thread):
#    def __init__(self, urlfiles):
#        threading.Thread.__init__(self)
#
#

def downloadProc(url, filename):

    #url = u'qvod://297167808|0225CE017F36A404BF7347ED306311E8BC96C9C8|小爸爸_HDTV_01.rmvb|'
    #fname = url.split('|')[-2]

    downloader.download(url, None, fname)


if __name__ == '__main__':
    if len(sys.argv) != 3:
        print '''usage: Pydownloader.py "qvod://297167808|0225CE017F36A404BF7347ED306311E8BC96C9C8|小爸爸_HDTV_01.rmvb|" "filename"'''
        os._exit(1)
    url = unicode(sys.argv[1])
    fname = unicode(sys.argv[2])
    ret = downloader.valid_url(url)
    if ret == False:
        print ''' the url is not a valid url '''
        os._exit(2)
    downloadProc(url, fname)
    os._exit(0)