Initial commit

This commit is contained in:
Julian Knauer 2017-09-29 08:42:22 +02:00
commit 26f4c7de6b
1 changed files with 43 additions and 0 deletions

43
pytorrentinfo.py Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env python3
import sys
import os
import glob
from torrentool.api import Torrent
"""
'announce_urls', 'comment', 'create_from', 'created_by', 'creation_date', 'files', 'from_file', 'from_string',
'get_magnet', 'httpseeds', 'info_hash', 'magnet_link', 'name', 'private', 'to_file', 'to_string', 'total_size',
'webseeds']
"""
def parse_torrent_file(torrentfile, list_contents=True):
torrent = Torrent.from_file(torrentfile)
print('+- Torrent : {}'.format(os.path.basename(torrentfile)))
print('| Title : {}'.format(torrent.name))
print('| Comment : {}'.format(torrent.comment or 'n/a'))
try:
print('| Size : {} bytes'.format(torrent.total_size))
except:
print('| Size : {}'.format('n/a'))
print('| Created : {}'.format(torrent.creation_date or 'n/a'))
print('| Hash : {}'.format(torrent.info_hash))
if torrent.comment:
print('| Comment : {}'.format(torrent.comment))
if len(torrent.httpseeds) > 0:
print('| httpseeds: {}'.format(torrent.httpseeds))
if len(torrent.webseeds) > 0:
print('| webseeds : {}'.format(torrent.webseeds))
if list_contents:
for index, fileinfo in enumerate(torrent.files):
print('| FILE[{:4}] name = {}'.format(index, fileinfo[0]))
print('| FILE[{:4}] size = {}'.format(index, fileinfo[1]))
if __name__ == '__main__':
for index, torrentfile in enumerate(glob.glob('D:\\XWF\\CASE\\EY_MAIN_DRAG\\MAIN DRAG Teil 2\\ASS20_HDD01, P1\\Ex\\Documents and Settings\\Administrator\\Application Data\\Azureus\\active\\*.torrent')):
torrentfile = torrentfile.replace('\\', '\\')
parse_torrent_file(torrentfile, False)
print('Found {} .torrent files.'.format(index+1))