From 1864bb13c5b77300e79230654012954d6ad70f12 Mon Sep 17 00:00:00 2001
From: MaxE <29448127+EMaX0@users.noreply.github.com>
Date: Sun, 16 Feb 2020 18:44:03 +0800
Subject: [PATCH] Updated wstream.py and cineblog01.py (#190)
* updated test_video_exists
Updated test_video_exists() to try int_bckup_method if post is blank
* updated findvid_serie
Using split to break blocks of links within the episode.
Added blktxt (i.e. HD, Nova, Ubi...) when there are block of video with different quality within the same episode
---
channels/cineblog01.py | 40 +++++++++++-----------------------------
servers/wstream.py | 15 +++++++++++----
2 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/channels/cineblog01.py b/channels/cineblog01.py
index 8619b218..f7c799e3 100644
--- a/channels/cineblog01.py
+++ b/channels/cineblog01.py
@@ -246,7 +246,7 @@ def findvid_serie(item):
matches = re.compile(patron, re.DOTALL).finditer(html)
for match in matches:
scrapedurl = match.group(1)
- scrapedtitle = match.group(2)
+ scrapedtitle = ("%s" % support.color(blktxt,"orange") + " - " if blktxt else "") + match.group(2)
# title = item.title + " [COLOR blue][" + scrapedtitle + "][/COLOR]"
itemlist.append(
Item(channel=item.channel,
@@ -266,34 +266,16 @@ def findvid_serie(item):
lnkblkp = []
data = item.url
-
- # First blocks of links
- if data[0:data.find(' 0:
- lnkblk.append(data[data.find(' - ') + 3:data[0:data.find(']+>[^<]+([^<]+)'
- matches = re.compile(patron, re.DOTALL).finditer(data)
- for match in matches:
- sep = match.group(1)
- if sep != ' - ':
- lnkblk.append(sep)
-
- i = 0
- if len(lnkblk) > 1:
- for lb in lnkblk[1:]:
- lnkblkp.append(data.find(lb, lnkblkp[i] + len(lnkblk[i])))
- i = i + 1
-
- for i in range(0, len(lnkblk)):
- if i == len(lnkblk) - 1:
- load_vid_series(data[lnkblkp[i]:], item, itemlist, lnkblk[i])
- else:
- load_vid_series(data[lnkblkp[i]:lnkblkp[i + 1]], item, itemlist, lnkblk[i])
+
+ # Blocks with split
+ blk=re.split("(?:>\s*)?([A-Za-z\s0-9]*):\s*<",data,re.S)
+ blktxt=""
+ for b in blk:
+ if b[0:3]=="a h" or b[0:4]==""%b, item, itemlist, blktxt)
+ blktxt=""
+ elif len(b.strip())>1:
+ blktxt=b.strip()
return support.server(item, itemlist=itemlist)
diff --git a/servers/wstream.py b/servers/wstream.py
index 02853a54..37de2ad0 100644
--- a/servers/wstream.py
+++ b/servers/wstream.py
@@ -14,6 +14,12 @@ from platformcode import logger, config
headers = [['User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0']]
def test_video_exists(page_url):
+ def int_bckup_method():
+ global data,headers
+ page_url = scrapertools.find_single_match(data, r"""|>)""")
if possibleParam:
post = urllib.urlencode({param[0]: param[1] for param in possibleParam if param[0]})
- data = httptools.downloadpage(page_url, headers=headers, post=post, follow_redirects=True).data
+ if post:
+ data = httptools.downloadpage(page_url, headers=headers, post=post, follow_redirects=True).data
+ else:
+ int_bckup_method()
else:
- page_url = scrapertools.find_single_match(data, r"""