def __init__(self, src = None, dest = None, forceasklocation = False, caller = ""): self.src = src # List values self.list = utility.window.list self.listbitmap = 0 # Meta data if self.src.startswith(MAGNET_PREFIX): self.metainfo = FakeMetaData(self.src) self.infohash = getHash(self.src, asHex = True) self.src = self.src[len(MAGNET_PREFIX):] self.info = self.metainfo['info'] self.rawinfo = "" self.hasMetadata = False else: self.metainfo = self.getResponse(force=True) if self.metainfo: self.infohash = sha1(bencode(self.metainfo['info'])).hexdigest() self.info = self.metainfo['info'] self.rawinfo = bencode(self.metainfo['info']) self.hasMetadata = True if self.metainfo is None: return # Tracker List if 'announce-list' in self.metainfo: self.originalTrackers = self.metainfo['announce-list'] elif 'announce' in self.metainfo: self.originalTrackers = [[self.metainfo['announce']]] else: self.originalTrackers = [] self.trackerlist = self.originalTrackers # Torrent Handlers self.torrentconfig = TorrentConfig(self) self.status = TorrentStatus(self) self.actions = TorrentActions(self) self.dialogs = TorrentDialogs(self) self.connection = TorrentConnections(self) # Info section self.InitializeInfo() self.files.setupDest(dest, forceasklocation, caller)
def __init__(self, magnetURI): self['info'] = {} try: magnetURI = str(magnetURI) except UnicodeEncodeError: pass tracker = getArgument(magnetURI, 'tr') if tracker: self['announce'] = forceunicode(unquote(tracker)) name = getArgument(magnetURI, 'dn') if name: self['info']['name'] = unquote(name) + ".torrent" else: self['info']['name'] = getHash(magnetURI, asHex = True) + ".torrent" self['info']['length'] = 1 self['info']['piece length'] = 1024 self['info']['pieces'] = " "*20