Exemplo n.º 1
0
 def downloadLoop(self, title):
     db = DownloadDB()
     status = 'downloading'
     while db.get(title) and status != 'stopped':
         xbmc.sleep(3000)
         status = db.get_status(title)
         if not self.paused:
             if status == 'pause':
                 self.paused = True
                 self.session.pause()
         else:
             if status != 'pause':
                 self.paused = False
                 self.session.resume()
         s = self.torrentHandle.status()
         info = {}
         info['upload'] = s.upload_payload_rate
         info['download'] = s.download_payload_rate
         info['peers'] = s.num_peers
         info['seeds'] = s.num_seeds
         iterator = int(s.progress * 100)
         info['progress'] = iterator
         db.update(title, info)
         self.debug()
     self.session.remove_torrent(self.torrentHandle)
     return
Exemplo n.º 2
0
    def downloadProcess(self, contentId):
        self.startSession()
        self.paused = False
        db = DownloadDB()
        ContentList = self.getContentList()
        if contentId != None: contentId = int(contentId)
        if len(ContentList) == 1 or contentId not in [None, -1]:
            if not contentId: contentId = 0
            title = os.path.basename(ContentList[contentId]['title'])
            path = os.path.join(self.storageDirectory, ContentList[contentId]['title'])
            type = 'file'
        else:
            contentId = -1
            title = ContentList[0]['title'].split('\\')[0]
            path = os.path.join(self.storageDirectory, title)
            type = 'folder'

        add = db.add(title, path, type, {'progress': 0}, 'downloading', self.torrentFile, contentId,
                     self.storageDirectory)
        get = db.get(title)
        if add or get[5] == 'stopped':
            if get[5] == 'stopped':
                db.update_status(get[0], 'downloading')
            if contentId not in [None, -1]:
                self.continueSession(int(contentId), Offset=0, seeding=False)
            else:
                for i in range(self.torrentFileInfo.num_pieces()):
                    self.torrentHandle.piece_priority(i, 6)
            thread.start_new_thread(self.downloadLoop, (title,))
Exemplo n.º 3
0
 def downloadLoop(self, title):
     db = DownloadDB()
     status = 'downloading'
     while db.get(title) and status != 'stopped':
         xbmc.sleep(3000)
         status = db.get_status(title)
         if not self.paused:
             if status == 'pause':
                 self.paused = True
                 self.session.pause()
         else:
             if status != 'pause':
                 self.paused = False
                 self.session.resume()
         s = self.torrentHandle.status()
         info = {}
         info['upload'] = s.upload_payload_rate
         info['download'] = s.download_payload_rate
         info['peers'] = s.num_peers
         info['seeds'] = s.num_seeds
         iterator = int(s.progress * 100)
         info['progress'] = iterator
         db.update(title, info)
         self.debug()
     self.session.remove_torrent(self.torrentHandle)
     return
Exemplo n.º 4
0
    def downloadProcess(self, contentId, encrytion=True):
        self.initSession()
        if encrytion:
            self.encryptSession()
        self.startSession()
        self.paused = False
        db = DownloadDB()
        ContentList = self.getContentList()
        if contentId != None: contentId = int(contentId)
        if len(ContentList) == 1 or contentId not in [None, -1]:
            if not contentId: contentId = 0
            title = os.path.basename(ContentList[contentId]['title'])
            path = os.path.join(self.storageDirectory, ContentList[contentId]['title'])
            type = 'file'
        else:
            contentId = -1
            title = ContentList[0]['title'].split('\\')[0]
            path = os.path.join(self.storageDirectory, title)
            type = 'folder'

        add = db.add(title, path, type, {'progress': 0}, 'downloading', self.torrentFile, contentId,
                     self.storageDirectory)
        get = db.get(title)
        if add or get[5] == 'stopped':
            if get[5] == 'stopped':
                db.update_status(get[0], 'downloading')
            if contentId not in [None, -1]:
                self.continueSession(int(contentId), Offset=0, seeding=False)
            else:
                for i in range(self.torrentFileInfo.num_pieces()):
                    self.torrentHandle.piece_priority(i, 6)
            thread.start_new_thread(self.downloadLoop, (title,))
Exemplo n.º 5
0
 def db_delete(self):
     db = DownloadDB()
     get = db.get(self.basename)
     if get:
         db.delete(get[0])
Exemplo n.º 6
0
 def db_delete(self):
     if self.basename:
         db = DownloadDB()
         get = db.get(self.basename)
         if get:
             db.delete(get[0])