:// protocol for mancuniancol

pull/15/head
DiMartinoXBMC 2016-12-13 19:12:14 +03:00
parent 792823b25b
commit ef180cc215
4 changed files with 112 additions and 51 deletions

View File

@ -25,7 +25,7 @@ import hashlib
import re
import base64
from StringIO import StringIO
import gzip
import zlib
from functions import file_decode, file_encode
from functions import magnet_alert, log, debug
@ -93,19 +93,12 @@ class AceStream:
torrentFile = self.storageDirectory + os.sep + self.torrentFilesDirectory + os.sep + self.md5(
torrentUrl) + '.torrent'
try:
if not re.match("^http\:.+$", torrentUrl):
content = xbmcvfs.File(file_decode(torrentUrl), "rb").read()
if not re.match("^[htps]+?://.+$|^://.+$", torrentUrl):
log('xbmcvfs.File for %s' % torrentUrl)
content = xbmcvfs.File(torrentUrl, "rb").read()
else:
request = urllib2.Request(torrentUrl)
request.add_header('Referer', torrentUrl)
request.add_header('Accept-encoding', 'gzip')
result = urllib2.urlopen(request)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
f = gzip.GzipFile(fileobj=buf)
content = f.read()
else:
content = result.read()
log('request for %s' % torrentUrl)
content = self.makeRequest(torrentUrl)
localFile = xbmcvfs.File(torrentFile, "w+b")
localFile.write(content)
@ -119,6 +112,29 @@ class AceStream:
self.torrentFileInfo = self.TSplayer.load_torrent(base64.b64encode(content), 'RAW')
return self.torrentFile
def makeRequest(self, torrentUrl):
torrentUrl = re.sub('^://', 'http://', torrentUrl)
x = re.search("://(.+?)/|://(.+?)$", torrentUrl)
if x:
baseurl = x.group(1) if x.group(1) else x.group(2)
else:
baseurl =''
headers = [('User-Agent',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'),
('Referer', 'http://%s/' % baseurl), ('Accept-encoding', 'gzip'), ]
opener = urllib2.build_opener()
opener.addheaders = headers
result = opener.open(torrentUrl)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
return content
def magnetToTorrent(self, magnet):
try:
from SkorbaLoader import SkorbaLoader

View File

@ -200,19 +200,12 @@ class AnteoLoader:
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
try:
if not re.match("^http\:.+$", torrentUrl):
if not re.match("^[htps]+?://.+$|^://.+$", torrentUrl):
log('xbmcvfs.File for %s' % torrentUrl)
content = xbmcvfs.File(torrentUrl, "rb").read()
else:
request = urllib2.Request(torrentUrl)
request.add_header('Referer', torrentUrl)
request.add_header('Accept-encoding', 'gzip')
result = urllib2.urlopen(request)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
log('request for %s' % torrentUrl)
content = self.makeRequest(torrentUrl)
localFile = xbmcvfs.File(torrentFile, "w+b")
localFile.write(content)
@ -229,6 +222,29 @@ class AnteoLoader:
self.torrentFile = torrentFile
return self.torrentFile
def makeRequest(self, torrentUrl):
torrentUrl = re.sub('^://', 'http://', torrentUrl)
x = re.search("://(.+?)/|://(.+?)$", torrentUrl)
if x:
baseurl = x.group(1) if x.group(1) else x.group(2)
else:
baseurl =''
headers = [('User-Agent',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'),
('Referer', 'http://%s/' % baseurl), ('Accept-encoding', 'gzip'), ]
opener = urllib2.build_opener()
opener.addheaders = headers
result = opener.open(torrentUrl)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
return content
def md5(self, string):
hasher = hashlib.md5()
try:

View File

@ -168,20 +168,12 @@ class InposLoader:
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
torrentFile = localize_path(os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent'))
try:
if not re.match("^http\:.+$", torrentUrl):
if not re.match("^[htps]+?://.+$|^://.+$", torrentUrl):
log('xbmcvfs.File for %s' % torrentUrl)
content = xbmcvfs.File(torrentUrl, "rb").read()
else:
request = urllib2.Request(torrentUrl)
request.add_header('Referer', torrentUrl)
request.add_header('Accept-encoding', 'gzip')
result = urllib2.urlopen(request)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
log('request for %s' % torrentUrl)
content = self.makeRequest(torrentUrl)
localFile = xbmcvfs.File(torrentFile, "w+b")
localFile.write(content)
localFile.close()
@ -197,6 +189,29 @@ class InposLoader:
self.torrentFile = torrentFile
return self.torrentFile
def makeRequest(self, torrentUrl):
torrentUrl = re.sub('^://', 'http://', torrentUrl)
x = re.search("://(.+?)/|://(.+?)$", torrentUrl)
if x:
baseurl = x.group(1) if x.group(1) else x.group(2)
else:
baseurl =''
headers = [('User-Agent',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'),
('Referer', 'http://%s/' % baseurl), ('Accept-encoding', 'gzip'), ]
opener = urllib2.build_opener()
opener.addheaders = headers
result = opener.open(torrentUrl)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
return content
def md5(self, string):
hasher = hashlib.md5()
try:

View File

@ -95,21 +95,12 @@ class SkorbaLoader:
xbmcvfs.mkdirs(self.torrentFilesPath)
torrentFile = localize_path(os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent'))
try:
if not re.match("^http\:.+$", torrentUrl):
contentFile = xbmcvfs.File(torrentUrl, "rb")
content = contentFile.read()
contentFile.close()
if not re.match("^[htps]+?://.+$|^://.+$", torrentUrl):
log('xbmcvfs.File for %s' % torrentUrl)
content = xbmcvfs.File(torrentUrl, "rb").read()
else:
request = urllib2.Request(torrentUrl)
request.add_header('Referer', torrentUrl)
request.add_header('Accept-encoding', 'gzip')
result = urllib2.urlopen(request)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
log('request for %s' % torrentUrl)
content = self.makeRequest(torrentUrl)
localFile = xbmcvfs.File(torrentFile, "w+b")
localFile.write(content)
@ -144,7 +135,30 @@ class SkorbaLoader:
self.torrentFileInfo = self.lt.torrent_info(e)
self.torrentFile = torrentFile
return self.torrentFile
def makeRequest(self, torrentUrl):
torrentUrl = re.sub('^://', 'http://', torrentUrl)
x = re.search("://(.+?)/|://(.+?)$", torrentUrl)
if x:
baseurl = x.group(1) if x.group(1) else x.group(2)
else:
baseurl =''
headers = [('User-Agent',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'),
('Referer', 'http://%s/' % baseurl), ('Accept-encoding', 'gzip'), ]
opener = urllib2.build_opener()
opener.addheaders = headers
result = opener.open(torrentUrl)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
content = decomp.decompress(buf.getvalue())
else:
content = result.read()
return content
def getMagnetInfo(self):
magnetSettings = {
'url': self.magnetLink,