Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gziped torrents #8

Open
KD8EYF opened this issue Aug 30, 2013 · 4 comments
Open

gziped torrents #8

KD8EYF opened this issue Aug 30, 2013 · 4 comments

Comments

@KD8EYF
Copy link

KD8EYF commented Aug 30, 2013

on some torrent feeds the .torrent files are actually gziped without a .gz extension, this causes

"Create new temporary directory... done!
Now fetching the bittorrent data
Download Error: not a valid bencoded string
Traceback (most recent call last):
File "/usr/share/mythnettv/mythnettvcore.py", line 121, in DownloadAndImport
out=out) == True:
File "/usr/share/mythnettv/program.py", line 441, in Download
verbose=FLAGS.verbose, out=out)
File "/usr/share/mythnettv/plugins/bittorrent.py", line 70, in Download
metainfo = bencode.bdecode(torrent_file.read())
File "/usr/local/lib/python2.7/dist-packages/bencode-1.0-py2.7.egg/bencode/init.py", line 68, in bdecode
raise BTFailure("not a valid bencoded string")
BTFailure: not a valid bencoded string
"

changing
torrent_file = open(torrent_filename)
to
torrent_file = gzip.open(torrent_filename)
works..
Ill see if i can make the auto detect a gzip header and decompress if it is

@managementboy
Copy link
Owner

any kind of help is apreciated

@disputin
Copy link
Contributor

did you ever get this solved? This might help

import gzip
import magic

m=magic.open(magic.MAGIC_MIME)
m.load()
if 'x-gzip' in m.file(filename):
    filetmp = filename+'.gz' 
    os.rename(filename,filetmp)
     f_in = gzip.open(filetmp, 'rb')
     f_out = open(filename, 'wb')
     f_out.writelines(f_in)
     f_out.close()
     f_in.close()
     os.remove(filetmp)

@managementboy
Copy link
Owner

no I have not. I am unhappy with adding another dependency (magic) to the
code.

2013/11/13 Sean Whitney [email protected]

did you ever get this solved? This might help

import gzipimport magic
m=magic.open(magic.MAGIC_MIME)m.load()if 'x-gzip' in m.file(filename):
filetmp = filename+'.gz'
os.rename(filename,filetmp)
f_in = gzip.open(filetmp, 'rb')
f_out = open(filename, 'wb')
f_out.writelines(f_in)
f_out.close()
f_in.close()
os.remove(filetmp)


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-28405238
.

@managementboy
Copy link
Owner

fixed in e500fbb
mntv now requires python-magic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants