Added option to print shortend output for torrent info

This commit is contained in:
Julian Knauer 2017-09-29 11:03:12 +02:00
parent 26f4c7de6b
commit 6739410172

View File

@ -13,15 +13,16 @@ from torrentool.api import Torrent
"""
def parse_torrent_file(torrentfile, list_contents=True):
def parse_torrent_file(torrentfile, short_output=False, 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'))
if not short_output:
print('| Comment : {}'.format(torrent.comment or 'n/a'))
print('| Created : {}'.format(torrent.creation_date or 'n/a'))
print('| Hash : {}'.format(torrent.info_hash))
if torrent.comment:
@ -39,5 +40,5 @@ def parse_torrent_file(torrentfile, list_contents=True):
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)
parse_torrent_file(torrentfile, True, False)
print('Found {} .torrent files.'.format(index+1))