Beispiel #1
0
 def download_file(self, title, download_link):
     wmafile = urllib2.urlopen(download_link)
     # print '[DOWNLOADING ' + title + ' ]'
     colorful.printc('[DOWNLOADING ' + title + ' ]', 'OKBLUE')
     output = open('music/' + title + '.mp3','wb')
     output.write(wmafile.read())
     output.close()         
Beispiel #2
0
    def run_billboard(self):
        #subprocess.call('scrapy crawl billboard', shell=True)
        if len(sys.argv) == 2:
            if sys.argv[1] == 'billboard':
                subprocess.call('scrapy crawl billboard', shell=True)
            elif sys.argv[1] == 'sogou':
                subprocess.call('scrapy crawl sogou', shell=True)
            else:
				colorful.printc('[NO SUCH SPIDER]', 'FAIL')	
        else:
			colorful.printc('[INPUT FORMAT python music spider]', 'WARNING')
Beispiel #3
0
 def run(self):
     while True:
         if self.download_requests.empty() is False:
             request = self.download_requests.get()
             type = request[0]
             title = request[1]
             download_link = request[2]
             
             if type == 'TERMINATE':
                 self.download_requests.put(('TERMINATE', '--', '--'))
                 break
             else:     
                 for i in range(0, 2):
                     try:
                         self.download_file(title, download_link)
                         break
                     except:
                         # print '[OOPS BAD LINK]'
                         colorful.printc('[OOPS BAD LINK]', 'FAIL')
Beispiel #4
0
 def sock_listen(self):
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.bind(self.addr)
     s.listen(100)
     
     while True:
         conn, addr = s.accept()
         msg = conn.recv(1024).decode('utf-8')
         
         args = msg.split('[*]')
         type = args[0]
         title = args[1]
         download_link = args[2]
         
         if type == 'TERMINATE':
             # print '[CLOSING SOCKET]'
             colorful.printc('[CLOSING SOCKET]', 'WARNING')
             self.download_requests.put((type, title, download_link))
             break
         else:
             self.download_requests.put((type, title, download_link))
         conn.close()
     s.close()
Beispiel #5
0
 def wait4stop(self):
     for i in range(0, self.NUM_DOWNLOADERS):
         self.downloaders[i].join()
     colorful.printc('[MISSION COMPLETE]', 'OKGREEN') 
Beispiel #6
0
 def spider_closed(self, spider):
     #log.msg("closed spider %s" % spider.name)
     # print '[INFO GATHERING COMPLETE]'
     colorful.printc('[INFO GATHERING COMPLETE]', 'WARNING')
     self.sock.send_msg('TERMINATE[*]--[*]--')
Beispiel #7
0
 def spider_opened(self, spider):
     #log.msg("opened spider %s" % spider.name)
     # print '[START TO CRAWL SONGS]'
     colorful.printc('[START TO CRAWL SONGS]', 'WARNING')