Exemplo n.º 1
0
    def saveTorrent(self, torrentUrl):
        if re.match("^magnet\:.+$", torrentUrl):
            magnet_alert()
            exit()
        else:
            torrentFile = self.storageDirectory + os.sep + self.torrentFilesDirectory + os.sep + self.md5(
                torrentUrl) + '.torrent'
            try:
                if not re.match("^http\:.+$", torrentUrl):
                    content = xbmcvfs.File(file_decode(torrentUrl), "rb").read()
                else:
                    request = urllib2.Request(torrentUrl)
                    request.add_header('Referer', torrentUrl)
                    request.add_header('Accept-encoding', 'gzip')
                    result = urllib2.urlopen(request)
                    if result.info().get('Content-Encoding') == 'gzip':
                        buf = StringIO(result.read())
                        f = gzip.GzipFile(fileobj=buf)
                        content = f.read()
                    else:
                        content = result.read()

                localFile = xbmcvfs.File(torrentFile, "w+b")
                localFile.write(content)
                localFile.close()
            except Exception, e:
                print 'Unable to save torrent file from "' + torrentUrl + '" to "' + torrentFile + '" in Torrent::saveTorrent' + '. Exception: ' + str(
                    e)
                return
            if xbmcvfs.exists(torrentFile):
                self.torrentFile = torrentFile
                self.torrentFileInfo = self.TSplayer.load_torrent(base64.b64encode(content), 'RAW')
                return self.torrentFile
Exemplo n.º 2
0
    def saveTorrent(self, torrentUrl):
        if re.match("^magnet\:.+$", torrentUrl):
            magnet_alert()
            exit()
        else:
            torrentFile = self.storageDirectory + os.sep + self.torrentFilesDirectory + os.sep + self.md5(
                torrentUrl) + '.torrent'
            try:
                if not re.match("^http\:.+$", torrentUrl):
                    content = xbmcvfs.File(file_decode(torrentUrl),
                                           "rb").read()
                else:
                    request = urllib2.Request(torrentUrl)
                    request.add_header('Referer', torrentUrl)
                    request.add_header('Accept-encoding', 'gzip')
                    result = urllib2.urlopen(request)
                    if result.info().get('Content-Encoding') == 'gzip':
                        buf = StringIO(result.read())
                        f = gzip.GzipFile(fileobj=buf)
                        content = f.read()
                    else:
                        content = result.read()

                localFile = xbmcvfs.File(torrentFile, "w+b")
                localFile.write(content)
                localFile.close()
            except Exception, e:
                print 'Unable to save torrent file from "' + torrentUrl + '" to "' + torrentFile + '" in Torrent::saveTorrent' + '. Exception: ' + str(
                    e)
                return
            if xbmcvfs.exists(torrentFile):
                self.torrentFile = torrentFile
                self.torrentFileInfo = self.TSplayer.load_torrent(
                    base64.b64encode(content), 'RAW')
                return self.torrentFile
Exemplo n.º 3
0
 def magnetToTorrent(self, magnet):
     try:
         from Libtorrent import Libtorrent
         torrent = Libtorrent(self.storageDirectory, magnet)
         torrent.magnetToTorrent(magnet)
         self.torrentFile = torrent.torrentFile
         log('[AceStream][magnetToTorrent]: self.torrentFile '+str(self.torrentFile))
         return self.torrentFile
     except:
         magnet_alert()
         exit()
Exemplo n.º 4
0
 def magnetToTorrent(self, magnet):
     try:
         from SkorbaLoader import SkorbaLoader
         torrent = SkorbaLoader(self.storageDirectory, magnet)
         torrent.magnetToTorrent(magnet)
         self.torrentFile = torrent.torrentFile
         log('[AceStream][magnetToTorrent]: self.torrentFile '+str(self.torrentFile))
         return self.torrentFile
     except:
         magnet_alert()
         exit()
Exemplo n.º 5
0
class AceStream:
    try:
        fpath = os.path.expanduser("~")
        pfile = os.path.join(fpath, 'AppData\Roaming\ACEStream\engine',
                             'acestream.port')
        gf = open(pfile, 'r')
        aceport = int(gf.read())
        gf.close()
        print aceport
    except:
        aceport = 62062

    torrentFile = None
    magnetLink = None
    storageDirectory = ''
    torrentFilesDirectory = 'torrents'
    startPart = 0
    endPart = 0
    partOffset = 0
    torrentHandle = None
    session = None
    downloadThread = None
    threadComplete = False
    lt = None

    def __init__(self,
                 storageDirectory='',
                 torrentFile='',
                 torrentFilesDirectory='torrents'):
        try:
            from ASCore import TSengine as tsengine

            print 'Imported TSengine from ASCore'
        except Exception, e:
            print 'Error importing TSengine from ASCore. Exception: ' + str(e)
            return

        self.TSplayer = tsengine()
        del tsengine
        self.torrentFilesDirectory = torrentFilesDirectory
        self.storageDirectory = storageDirectory
        _path = os.path.join(self.storageDirectory,
                             self.torrentFilesDirectory) + os.sep
        if not xbmcvfs.exists(_path):
            xbmcvfs.mkdirs(_path)
        if xbmcvfs.exists(torrentFile):
            self.torrentFile = torrentFile
            content = xbmcvfs.File(torrentFile, "rb").read()
            self.torrentFileInfo = self.TSplayer.load_torrent(
                base64.b64encode(content), 'RAW')
        elif re.match("^magnet\:.+$", torrentFile):
            magnet_alert()
            exit()
Exemplo n.º 6
0
 def magnetToTorrent(self, magnet):
     magnet_alert()
     exit()
Exemplo n.º 7
0
 def getMagnetInfo(self):
     magnet_alert()
     exit()
Exemplo n.º 8
0
 def magnetToTorrent(self, magnet):
     magnet_alert()
     exit()
Exemplo n.º 9
0
 def getMagnetInfo(self):
     magnet_alert()
     exit()