Beispiel #1
0
                peers = None
                torrentFileName = None
                rawLinkTorrent = None
                ns = {'torrent':'//kastatic.com/xmlns/0.1/'}
                for aTorrentFile in anItem.findall('torrent:seeds', ns):
                    seeds= int(aTorrentFile.text)
                for aTorrentFile in anItem.findall('torrent:peers', ns):
                    peers = int(aTorrentFile.text)
                for aTorrentFile in anItem.findall('torrent:fileName', ns):
                    title = (aTorrentFile.text).replace('.torrent','')
                for aTorrentFile in anItem.iter('enclosure'):
                    rawLinkTorrent = aTorrentFile.attrib['url']
                    torrentFileName = (re.search('\?title=(.*)', rawLinkTorrent, re.IGNORECASE).group(1))+'.torrent'
                    linkTorrent = re.sub(r'\?title=.*', '', rawLinkTorrent)
                if torrentFileName is not None:
                    torrentList.append({'title':title, 'rawLink': rawLinkTorrent, 'link':linkTorrent, 'fileName': torrentFileName, 'seeds':seeds, 'peers': peers})
    if len(torrentList) > 0:
        sortedTorrent = sorted(torrentList, key=lambda k: k['seeds'], reverse=True)
        anIndex = 0
        for aTorrent in sortedTorrent:
            aTorrent['index'] = anIndex
            anIndex += 1
        aDisplayObject = DisplayListUtils()
        print('Choose the torrent to download for %s' % anEpisode)
        aDisplayObject.displayList(sortedTorrent,
                                   ['index', 'title', 'seeds', 'peers'],
                                   {'index':'c','title':'l','seeds':'c','peers':'c'})
        theChoice = InteractionUtils.query_int('> Make your Choice :')
        result.append({'title':anEpisode, 'link':sortedTorrent[theChoice]['rawLink']})
createWebPageReult(result, downloadDir)