コード例 #1
0
    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"])
コード例 #2
0
 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'])
コード例 #3
0
 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())
コード例 #4
0
 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(),
         )
コード例 #5
0
def read_torrents(supported_file_types = {".torrent"} , torrent_folder_path = "."):
  """iterate torrent location. return a dict:  date->torrent_number"""
  import os
  import re
  import codecs

  for dirname, dirnames, filenames in os.walk(torrent_folder_path):
    for filename in filenames:
      

      #only allow supported file
      file_extension = os.path.splitext(filename)[1]
      if file_extension not in supported_file_types: continue
      #get modified time

      filePath= os.path.join(dirname, filename)
      tt = DT.datetime.fromtimestamp(os.path.getmtime(filePath))
      #date_str = "%d_%02d_%02d"%(t.year, t.month, t.day)

      try:
        from torrentparse import TorrentParser
        tp = TorrentParser(filePath)
        #print tp.get_creation_date()," ",tp.get_total_size()

        info = tp.get_files_details()
        if len(info) == 1:
          dtype = os.path.splitext(info[0][0])[1]
          name = info[0][0]
        else:
          dtype = "folder"
          name = filename

        #date = DT.datetime.utcfromtimestamp(tp.get_creation_date())
        #if date == None: date = tt
        date = tt

        # print Torrent.select(Torrent.q.date == date).count()


        tor = Torrent(name = name, 
                      date = date,
                      dtype = dtype,
                      size = get_total_size(info)
                      )
        #print tor

      except Exception, e:
        #print type(filename)
        #print e
        pass
コード例 #6
0
ファイル: __init__.py プロジェクト: henrytrager/blissflixx
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
コード例 #7
0
ファイル: __init__.py プロジェクト: blissland/devflixx
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
コード例 #8
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'])
コード例 #9
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'])
コード例 #10
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 "===="
コード例 #11
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(self.test_data_dir, torrent_file))
         self.assertEqual(tp.get_client_name(), TORRENTS_INFO[torrent_file]['client_name'])
コード例 #12
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(self.test_data_dir, torrent_file))
         self.assertEqual(tp.get_tracker_url(), TORRENTS_INFO[torrent_file]['tracker_url'])
コード例 #13
0
 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('test_data/%s' % torrent_file)
         self.assertItemsEqual(tp.get_files_details(), TORRENTS_INFO[torrent_file]['file_details'])
コード例 #14
0
 def test_get_client_name(self):
     ''' Test getting Client name from a valid torrent file. '''          
     for torrent_file in TORRENTS_INFO:
         tp = TorrentParser('test_data/%s' % torrent_file)
         self.assertEqual(tp.get_client_name(), TORRENTS_INFO[torrent_file]['client_name'])
コード例 #15
0
 def test_get_creation_date(self):
     ''' Test getting creation date from a valid torrent file. ''' 
     for torrent_file in TORRENTS_INFO:
         tp = TorrentParser('test_data/%s' % torrent_file)
         self.assertEqual(tp.get_creation_date(), 
                          datetime.utcfromtimestamp(TORRENTS_INFO[torrent_file]['creation_date']).isoformat())