mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Fixed extratorrent.cc search engine.
This commit is contained in:
parent
2a5393cf53
commit
1290d7cac4
2 changed files with 13 additions and 6 deletions
|
@ -22,7 +22,7 @@
|
||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#VERSION: 1.32
|
#VERSION: 1.33
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
|
@ -35,6 +35,9 @@ import socket
|
||||||
import socks
|
import socks
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# Some sites blocks default python User-agent
|
||||||
|
user_agent = 'Mozilla/5.0'
|
||||||
|
headers = {'User-Agent': user_agent}
|
||||||
# SOCKS5 Proxy support
|
# SOCKS5 Proxy support
|
||||||
if os.environ.has_key("sock_proxy") and len(os.environ["sock_proxy"].strip()) > 0:
|
if os.environ.has_key("sock_proxy") and len(os.environ["sock_proxy"].strip()) > 0:
|
||||||
proxy_str = os.environ["sock_proxy"].strip()
|
proxy_str = os.environ["sock_proxy"].strip()
|
||||||
|
@ -61,7 +64,7 @@ def htmlentitydecode(s):
|
||||||
|
|
||||||
def retrieve_url(url):
|
def retrieve_url(url):
|
||||||
""" Return the content of the url page as a string """
|
""" Return the content of the url page as a string """
|
||||||
req = urllib2.Request(url)
|
req = urllib2.Request(url, headers)
|
||||||
response = urllib2.urlopen(req)
|
response = urllib2.urlopen(req)
|
||||||
dat = response.read()
|
dat = response.read()
|
||||||
# Check if it is gzipped
|
# Check if it is gzipped
|
||||||
|
@ -86,7 +89,7 @@ def download_file(url, referer=None):
|
||||||
file, path = tempfile.mkstemp()
|
file, path = tempfile.mkstemp()
|
||||||
file = os.fdopen(file, "w")
|
file = os.fdopen(file, "w")
|
||||||
# Download url
|
# Download url
|
||||||
req = urllib2.Request(url)
|
req = urllib2.Request(url, headers)
|
||||||
if referer is not None:
|
if referer is not None:
|
||||||
req.add_header('referer', referer)
|
req.add_header('referer', referer)
|
||||||
response = urllib2.urlopen(req)
|
response = urllib2.urlopen(req)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#VERSION: 1.33
|
#VERSION: 1.34
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
|
@ -35,6 +35,9 @@ import socket
|
||||||
import socks
|
import socks
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# Some sites blocks default python User-agent
|
||||||
|
user_agent = 'Mozilla/5.0'
|
||||||
|
headers = {'User-Agent': user_agent}
|
||||||
# SOCKS5 Proxy support
|
# SOCKS5 Proxy support
|
||||||
if "sock_proxy" in os.environ and len(os.environ["sock_proxy"].strip()) > 0:
|
if "sock_proxy" in os.environ and len(os.environ["sock_proxy"].strip()) > 0:
|
||||||
proxy_str = os.environ["sock_proxy"].strip()
|
proxy_str = os.environ["sock_proxy"].strip()
|
||||||
|
@ -61,7 +64,8 @@ def htmlentitydecode(s):
|
||||||
|
|
||||||
def retrieve_url(url):
|
def retrieve_url(url):
|
||||||
""" Return the content of the url page as a string """
|
""" Return the content of the url page as a string """
|
||||||
response = urllib.request.urlopen(url)
|
req = urllib.request.Request(url, headers)
|
||||||
|
response = urllib.request.urlopen(req)
|
||||||
dat = response.read()
|
dat = response.read()
|
||||||
# Check if it is gzipped
|
# Check if it is gzipped
|
||||||
if dat[:2] == b'\x1f\x8b':
|
if dat[:2] == b'\x1f\x8b':
|
||||||
|
@ -86,7 +90,7 @@ def download_file(url, referer=None):
|
||||||
file, path = tempfile.mkstemp()
|
file, path = tempfile.mkstemp()
|
||||||
file = os.fdopen(file, "wb")
|
file = os.fdopen(file, "wb")
|
||||||
# Download url
|
# Download url
|
||||||
req = urllib.request.Request(url)
|
req = urllib.request.Request(url, headers)
|
||||||
if referer is not None:
|
if referer is not None:
|
||||||
req.add_header('referer', referer)
|
req.add_header('referer', referer)
|
||||||
response = urllib.request.urlopen(req)
|
response = urllib.request.urlopen(req)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue