def test_get_files_details(self):
     ''' Test getting the name, length and checksum of the files inside a valid torrent file. '''
     import os
     for torrent_file in TORRENTS_INFO:
         tp = TorrentParser(os.path.join(test_data_dir, torrent_file))
         self.assertItemsEqual(tp.get_files_details(),
                               TORRENTS_INFO[torrent_file]['file_details'])
 def test_get_creation_date(self):
     ''' Test getting creation date from a valid torrent file. '''
     for torrent_file in TORRENTS_INFO:
         tp = TorrentParser(os.path.join(test_data_dir, torrent_file))
         self.assertEqual(
             tp.get_creation_date(),
             datetime.utcfromtimestamp(
                 TORRENTS_INFO[torrent_file]['creation_date']).isoformat())
Beispiel #3
0
def torrent_files(link):
    if link.startswith("magnet:"):
        torrent = magnet2torrent(link)
    else:
        # Remove any parameters from torrent link
        # as some sites may not download if wrong
        idx = link.find('?')
        if idx > -1:
            link = link[:idx]
        r = chanutils.get(link)
        torrent = r.content

    files = None
    if torrent:
        try:
            parser = TorrentParser(torrent)
            files = parser.get_files_details()
        except Exception, e:
            pass
Beispiel #4
0
 def test_get_client_name(self):
     ''' Test getting Client name from a valid torrent file. '''
     for torrent_file in TORRENTS_INFO:
         tp = TorrentParser(os.path.join(test_data_dir, torrent_file))
         self.assertEqual(tp.get_client_name(), TORRENTS_INFO[torrent_file]['client_name'])
Beispiel #5
0
 def test_get_tracker_url(self):
     ''' Test getting Tracker URL from a valid torrent file. '''
     for torrent_file in TORRENTS_INFO:
         tp = TorrentParser(os.path.join(test_data_dir, torrent_file))
         self.assertEqual(tp.get_tracker_url(), TORRENTS_INFO[torrent_file]['tracker_url'])
Beispiel #6
0
import os
import sys
from torrentparse import TorrentParser

if len(sys.argv) > 1:
    torrent_files = sys.argv[1:]
    for torrent_file in torrent_files:
        if os.path.exists(torrent_file):
            print 'Parsing file {}'.format(torrent_file)
        else:
            sys.exit('Unable to find file {}'.format(torrent_file))

for torrent_file in torrent_files:
    tp = TorrentParser(torrent_file)
    print "Torrent File Name: %s" % torrent_file
    print "Track URL: %s" % tp.get_tracker_url()
    print "Tracker Creation Date: %s" % tp.get_creation_date()
    print "Tracker Client Name: %s" % tp.get_client_name()
    print "Tracker File Details: %s" % tp.get_files_details()
    print "===="