def fillSessionID(self): # if self.sessionID is None: pattern = r'(?<=X-Transmission-Session-Id: )[\d\w]+' req = urllib.request.Request(SendLink4Transmission.__url__) try: urllib.request.urlopen(req) except urllib.error.HTTPError as e: assert(e.code == 409) content = toUTF8(e.read()) self.sessionID = re.search(pattern, content).group()
def getMagnetLinkFromURL(url): if url.startswith('magnet'): return url content = toUTF8(getContentByURL(url)) return getMagnetLink(content)