Skip to content

Commit 7addf52

Browse files
v0.1.0 release
1 parent a9e2530 commit 7addf52

File tree

4 files changed

+101
-76
lines changed

4 files changed

+101
-76
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
.project
22
.pydevproject
33
*.pyc
4+
build/
5+
dist/
6+
torrentparse.egg-info/
7+
8+

README.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

README.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Author
2+
======
3+
4+
This is a patched version of https://github.com/mohanraj-r/torrentparse.
5+
The original readme follows.
6+
7+
What
8+
====
9+
10+
Parse a torrent file (bdecode) in Python without any 3rd party libraries
11+
and provide methods to access the following attributes
12+
13+
- tracker url,
14+
- creation date,
15+
- name of the client that created the torrent, and
16+
- for each file in the torrent \*\* name, length and checksum of the
17+
file (getting checksum is not implemented yet)
18+
19+
Why
20+
===
21+
22+
I was asked to write this as part of an interview process.
23+
24+
How
25+
===
26+
27+
Resources that I used to understand Torrent file structure:
28+
29+
- http://fileformats.wikia.com/wiki/Torrent\_file
30+
- http://wiki.theory.org/BitTorrentSpecification
31+
- http://en.wikipedia.org/wiki/Bencode
32+
- http://en.wikipedia.org/wiki/Torrent\_file
33+
34+
Example
35+
=======
36+
37+
The following stream of characters in the torrent file
38+
"d8:announce33:http://jip.cs.vu.nl:6969/announce13:creation
39+
datei1147934820e4:infod6:lengthi445866736e4:name24:Elephants\_Dream\_1024.avi12:piece
40+
lengthi262144e6:pieces34020:"
41+
42+
is transformed into {'creation date': 1147934820, 'announce':
43+
'http://jip.cs.vu.nl:6969/announce', 'info': {'length': 44 5866736,
44+
'piece length': 262144, 'name': 'Elephants\_Dream\_1024.avi', 'pieces':
45+
46+
The torrentparse python module takes torrent files as command line
47+
arguments, parses and prints info.
48+
49+
::
50+
51+
$ python torrentparse.py ../tests/test_data/wired-creative-commons-cd.torrent
52+
Parsing file ../tests/test_data/wired-creative-commons-cd.torrent
53+
../tests/test_data/wired-creative-commons-cd.torrent
54+
http://www.legaltorrents.com:7070/announce 2004-10-26T04:49:05 None [('01-beasti
55+
e-boys-now-get-busy.mp3', 5848493), ('02-david-byrne-my-fair-lady.mp3', 8484766)
56+
, ('03-zap-mama-wadidyusay.mp3', 8044860), ('04-my-morning-jacket-one-big-holida
57+
y.mp3', 12878571), ('05-spoon-revenge.mp3', 5928936), ('06-gilberto-gil-oslodum.
58+
mp3', 9528615), ('07-dan-the-automator-relaxation-spa-treatment.mp3', 8217290),
59+
('08-thievery-corporation-dc-3000.mp3', 10715627), ('09-le-tigre-fake-french.mp3
60+
', 6917415), ('10-paul-westerberg-looking-up-in-heaven.mp3', 7693791), ('11-chuc
61+
k-d-fine-arts-militia-no-meaning-no.mp3', 7717832), ('12-the-rapture-sister-savi
62+
our-blackstrobe-remix.mp3', 17020560), ('13-cornelius-wataridori-2.mp3', 1720025
63+
9), ('14-danger-mouse-jemini-what-u-sittin-on.mp3', 8329130), ('15-dj-dolores-os
64+
lodum-2004.mp3', 9621615), ('16-matmos-action-at-a-distance.mp3', 6588280), ('wi
65+
red-creative-commons-cd.txt', 3992)]
66+
********************************************************************************
67+
68+
It can also take multiple files or glob patterns.
69+
70+
::
71+
72+
$ python torrentparse.py ../tests/test_data/*.torrent
73+
...
74+
75+
If no files are given, it parses the test data files and prints info.
76+
77+
::
78+
79+
$ python torrentparse.py
80+
Parsing test torrent files ..
81+
torrentparse\tests\test_data\Elephants Dream (avi) (1024x576).torrent
82+
http://jip.cs.vu.nl:6969/announce 2006-05-18T06:47:00 None [('Elephants_Dream_1024.avi', 445866736)]
83+
...
84+
85+
Existing implementations
86+
========================
87+
88+
- http://pypi.python.org/pypi/BitTorrent-bencode/5.0.8
89+
- http://wiki.theory.org/Decoding\_bencoded\_data\_with\_python
90+
- http://effbot.org/zone/bencode.htm
91+

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
from setuptools import setup
44

55
setup(name='torrentparse',
6-
version='0.1',
6+
version='0.1.0',
77
description='torrentparse',
88
author='mohanraj-r',
9-
author_email='',
10-
url='https://github.com/mohanraj-r',
9+
author_email='mohanraj.cit@gmail.com',
10+
maintainer='James Broadhead',
11+
maintainer_email='jamesbroadhead+github@gmail.com',
12+
url='https://github.com/jamesbroadhead/torrentparse',
1113
packages = ['torrentparse'],
12-
#package_dir = {'': 'lib'},
1314
)

0 commit comments

Comments
 (0)