def getInfo(self) :
		''' builds an Info() object out of download informations '''
		obj=Info()
		obj.url=self.url
		obj.fileName=self.fileName
		obj.date=self.dt
		obj.time=self.tm
		obj.length=self.length
		
		return obj
Exemple #2
0
    def getInfo(self):
        ''' builds an Info() object out of download informations '''
        obj = Info()
        obj.url = self.url
        obj.fileName = self.fileName
        obj.date = self.dt
        obj.time = self.tm
        obj.length = self.length

        return obj
    def dumpRow(self, row):
        obj = Info()
        obj.url = str(self.cellWidget(row, 0).toolTip())
        obj.fileName = str(self.cellWidget(row, 0).text())
        obj.date = str(self.cellWidget(row, 4).text())
        obj.time = str(self.cellWidget(row, 5).text())

        self.wMutex.acquire(True)
        stat = self.dLI.DeleteNode(obj)
        self.wMutex.release()
        self.removeRow(row)
	def dumpRow(self,row) :
		obj=Info()
		obj.url=str(self.cellWidget(row,0).toolTip())
		obj.fileName=str(self.cellWidget(row,0).text())
		obj.date = str(self.cellWidget(row,4).text())		
		obj.time = str(self.cellWidget(row,5).text())
		
		self.wMutex.acquire(True)
		stat=self.dLI.DeleteNode(obj)		
		self.wMutex.release()
		self.removeRow(row)
    def getPartDownload(self, obj, packet, wMutex, bit):
        ''' When a download to be resumes it's partial information is fetched & download is resumed '''
        self.wMutex = wMutex
        self.packet = packet
        self.urlLabel.setText(str(obj.url)[0:80])
        self.recv = Queue()
        self.setWindowTitle(str(obj.url))

        self.outFile = obj.fileName
        self.dLength = int(obj.length)
        info = Info()
        info.url = obj.url
        info.fileName = obj.fileName
        info.date = obj.date
        info.time = obj.time
        info.length = obj.length

        obj = dLoadInfo().getSpecificInformation(obj)
        if obj == None:
            raise urllib2.URLError

        info.partition = obj.partition
        for i in range(len(info.partition)):
            self.dFile[obj.partition[i][0]] = None

        if obj == None:
            return 0
        else:
            if bit == 1:
                fName, length, cmtd = self.downloader.YTubePartition(
                    info, self.recv, self.PARTS, wMutex, self.dFlag, bit)
                self.PARTS = self.PARTS - cmtd
                if fName == None:
                    self.dLength = int(obj.length) - length
                    self.timer.start(1000)
                    return 1
                else:
                    self.packet.fileName = fName
                    self.packet.length = length
                    self.dLength = length
                    self.fileName = fName
                    self.outFile = fName
                    self.dLength = length
                    self.timer.start(1000)
                    return 2
        self.timer.start(1000)
        return 1
	def getPartDownload(self,obj,packet,wMutex,bit) :
		''' When a download to be resumes it's partial information is fetched & download is resumed '''
		self.wMutex=wMutex
		self.packet=packet
		self.urlLabel.setText(str(obj.url)[0:80])
		self.recv = Queue()
		self.setWindowTitle(str(obj.url))
		
		self.outFile=obj.fileName
		self.dLength=int(obj.length)
		info = Info()
		info.url=obj.url
		info.fileName=obj.fileName
		info.date=obj.date
		info.time=obj.time
		info.length=obj.length
		
		obj=dLoadInfo().getSpecificInformation(obj)
		if obj==None :
			raise urllib2.URLError
			
		info.partition=obj.partition
		for i in range(len(info.partition)) :
			self.dFile[obj.partition[i][0]]=None
			
		if obj == None :
			return 0
		else :
			if bit==1 :
				fName,length,cmtd=self.downloader.YTubePartition(info,self.recv,self.PARTS,wMutex,self.dFlag,bit)
				self.PARTS=self.PARTS-cmtd
				if fName==None  :
					self.dLength=int(obj.length)-length		
					self.timer.start(1000)
					return 1
				else :
					self.packet.fileName=fName
					self.packet.length=length
					self.dLength=length
					self.fileName=fName
					self.outFile = fName
					self.dLength=length
					self.timer.start(1000)
					return 2
		self.timer.start(1000)
		return 1
	def getDownload(self,url,packet,wMutex,bit=0) :
		self.wMutex=wMutex
		self.packet = packet
		self.urlLabel.setText(str(url)[0:80])
		self.recv = Queue()
		self.setWindowTitle(url)
		info = Info()
		info.url=url			
		info.date=self.packet.dt
		info.time=self.packet.tm
		if bit == 0 :
			self.outFile,self.dLength = self.downloader.YTubeDownload(url,self.recv,self.PARTS,info,wMutex,self.dFlag)
		else :
			self.outFile,self.dLength = self.downloader.Download(url,self.recv,self.PARTS,info,wMutex,self.dFlag)
			
		info.fileName=str(self.outFile)
		info.length=self.dLength
		self.info=info		
		
		self.Remaining.setText('Remaining : '+str(self.dLength)+' Bytes')
		self.timer.start(1000)
		return self.outFile,self.dLength
    def getDownload(self, url, packet, wMutex, bit=0):
        self.wMutex = wMutex
        self.packet = packet
        self.urlLabel.setText(str(url)[0:80])
        self.recv = Queue()
        self.setWindowTitle(url)
        info = Info()
        info.url = url
        info.date = self.packet.dt
        info.time = self.packet.tm
        if bit == 0:
            self.outFile, self.dLength = self.downloader.YTubeDownload(
                url, self.recv, self.PARTS, info, wMutex, self.dFlag)
        else:
            self.outFile, self.dLength = self.downloader.Download(
                url, self.recv, self.PARTS, info, wMutex, self.dFlag)

        info.fileName = str(self.outFile)
        info.length = self.dLength
        self.info = info

        self.Remaining.setText('Remaining : ' + str(self.dLength) + ' Bytes')
        self.timer.start(1000)
        return self.outFile, self.dLength