1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-09 06:17:58 +00:00

Workaround for torrentdownloads.net search engine (The web site seems partly broken though)

This commit is contained in:
Christophe Dumez 2010-06-02 22:26:52 +00:00
parent 63a0f4bf11
commit f4c29c07bf
2 changed files with 27 additions and 6 deletions

View File

@ -1,4 +1,4 @@
#VERSION: 1.01
#VERSION: 1.03
#AUTHORS: Christophe Dumez (chris@qbittorrent.org)
# Redistribution and use in source and binary forms, with or without
@ -27,9 +27,11 @@
from novaprinter import prettyPrinter
from helpers import retrieve_url, download_file
from helpers import retrieve_url
import StringIO, gzip, urllib2, tempfile
import sgmllib
import re
import os
class torrentdownloads(object):
url = 'http://www.torrentdownloads.net'
@ -40,8 +42,27 @@ class torrentdownloads(object):
self.results = []
self.parser = self.SimpleSGMLParser(self.results, self.url)
def download_torrent(self, info):
print download_file(info)
def download_torrent(self, url):
""" Download file at url and write it to a file, return the path to the file and the url """
file, path = tempfile.mkstemp()
file = os.fdopen(file, "w")
# Download url
req = urllib2.Request(url)
response = urllib2.urlopen(req)
dat = response.read()
# Check if it is gzipped
if dat[:2] == '\037\213':
# Data is gzip encoded, decode it
compressedstream = StringIO.StringIO(dat)
gzipper = gzip.GzipFile(fileobj=compressedstream)
extracted_data = gzipper.read()
dat = extracted_data
# Write it to a file
file.write(dat.strip())
file.close()
# return file path
print path+" "+url
class SimpleSGMLParser(sgmllib.SGMLParser):
def __init__(self, results, url, *args):
@ -108,4 +129,4 @@ class torrentdownloads(object):
if len(results) <= 0:
break
i += 1

View File

@ -4,4 +4,4 @@ btjunkie: 2.21
mininova: 1.40
piratebay: 1.30
vertor: 1.0
torrentdownloads: 1.01
torrentdownloads: 1.03