Skip to content

Commit 56af1dd

Browse files
committed
New upstream version 3.11.7
* небольшие правки HLS рестримера
2 parents 479a414 + 4db26a2 commit 56af1dd

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

ptv3/addon.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="ptv3"
33
name="Пазл Сервер 3.0"
4-
version="3.11.5"
4+
version="3.11.7"
55
provider-name="TDW">
66
<requires>
77
<import addon="xbmc.python" version="2.1.0"/>

ptv3/core.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ def __init__(self, param):
5151

5252
def run(self):
5353
Lu=get_stream(self.param['url'])
54-
try:r=test_url(Lu[0])
55-
except: r='404'
56-
if r!='404': update_Lt(Lu, self.param['n'], self.param['url'])
57-
else: update_Lt([], self.param['n'], self.param['url'])
54+
#try:r=test_url(Lu[0])
55+
#except: r='404'
56+
#if r!='404': update_Lt(Lu, self.param['n'], self.param['url'])
57+
#else: update_Lt([], self.param['n'], self.param['url'])
58+
update_Lt(Lu, self.param['n'], self.param['url'])
5859

5960

6061
def create_thread(param):
@@ -186,6 +187,7 @@ def inBL(url):
186187
def test_url(url):
187188
if 'udp://' in url: return '200'
188189
if 'rtmp://' in url: return '200'
190+
if '/restream/' in url: return '200'
189191

190192
if url in BanCashe: return 404
191193

@@ -1240,10 +1242,10 @@ def streams(id):
12401242
sn+=1
12411243
create_thread({'url':url, 'n':sn})
12421244

1243-
for t in range(60):
1245+
for t in range(4):
12441246
if len(Lthread) == len(urls): break
12451247
#if len(Lthread) > 1 and fplay =='true': break
1246-
time.sleep(0.31)
1248+
time.sleep(0.5)
12471249

12481250
for rst in Lthread:
12491251
Lst=rst['L']

ptv3/hls.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@ def get_UA(url):
1818
if i[0] in url: return i[1]
1919
return 'Opera/10.60 (X11; openSUSE 11.3/Linux i686; U; ru) Presto/2.6.30 Version/10.60'
2020

21+
def CRC32(buf):
22+
import binascii
23+
buf = (binascii.crc32(buf) & 0xFFFFFFFF)
24+
return str("%08X" % buf)
25+
26+
def save_cache(url, cache):
27+
try:
28+
fp=os.path.join(os.getcwd(), 'cache2', CRC32(url))
29+
fl = open(fp, "wb")
30+
fl.write(cache)
31+
fl.close()
32+
except: pass
33+
34+
def get_cache(url):
35+
try:
36+
fp=os.path.join(os.getcwd(), 'cache2', CRC32(url))
37+
fl = open(fp, "r")
38+
DT = fl.read()
39+
fl.close()
40+
return DT
41+
except:
42+
return None
43+
2144
class HLS():
2245
def __init__(self, hls_url, header='', list_index = -1):
2346
self.header = header
@@ -35,6 +58,8 @@ def __init__(self, hls_url, header='', list_index = -1):
3558
self.br_n = 0
3659

3760
def GET(self, url, Referer = 'http://ya.ru/'):
61+
#cache=get_cache(url)
62+
#if cache!=None: return cache
3863
try:
3964
urllib2.install_opener(urllib2.build_opener())
4065
req = urllib2.Request(url)
@@ -47,6 +72,7 @@ def GET(self, url, Referer = 'http://ya.ru/'):
4772
response = urllib2.urlopen(req, timeout=3)
4873
data=response.read()
4974
response.close()
75+
#save_cache(url, data)
5076
return data
5177
except:
5278
return None
@@ -133,11 +159,11 @@ def get_data2(self):
133159
else:
134160
head = self.hls_head
135161

136-
print head
162+
#print head
137163
if L[self.hls_n][:4]!='http': data_url = head+L[self.hls_n]
138164
else: data_url = L[self.hls_n]
139165

140-
print data_url#[-20:]
166+
print data_url[-20:]
141167
if data_url not in self.hls_complit:
142168

143169
data = self.GET(data_url, head)

ptv3/server.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import epg
1818
import hls
1919

20+
HLSBUF={}
2021

2122
buf = []
2223
trd = [0]
@@ -80,7 +81,7 @@ def get_ip():
8081
ip = get_ip()
8182

8283

83-
print('----- Starting PTV3 0.11.5 -----')
84+
print('----- Starting PTV3 0.11.7 -----')
8485
print('HELP: http://'+ip+':'+str(port))
8586
print('PLAYLIST: http://'+ip+':'+str(port)+'/playlist')
8687
trigger = True
@@ -1226,16 +1227,16 @@ def do_GET(self):
12261227
st = 0
12271228
while trigger:
12281229
n+=1
1229-
print n
1230-
part=HLS.get_data2()
1230+
#print n
1231+
part=HLS.get_data()
12311232
if part !=None:
12321233
self.wfile.write(part)
12331234
er=0
12341235
st=1
12351236
else:
1236-
if er>3 and st==0: break
1237-
if er>1000: break
12381237
er+=1
1238+
if st==0: break
1239+
if er>1000: break
12391240
time.sleep(0.5)
12401241
part = 'None'
12411242
print '== HLS END =='

ptv3/webui.files/notv.mp4

98.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)