From 4c67a9893135f8cce66e28beb42cf4901425ba78 Mon Sep 17 00:00:00 2001 From: CaptainTK Date: Fri, 27 Oct 2017 06:21:47 +0200 Subject: [plugin.video.iplayerwww] 3.0.18 (#1479) --- plugin.video.iplayerwww/addon.xml | 7 ++- .../resources/lib/ipwww_common.py | 2 +- .../resources/lib/ipwww_video.py | 52 +++++++++++++++------- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/plugin.video.iplayerwww/addon.xml b/plugin.video.iplayerwww/addon.xml index 49fdfe9..6a96773 100644 --- a/plugin.video.iplayerwww/addon.xml +++ b/plugin.video.iplayerwww/addon.xml @@ -1,5 +1,5 @@ - + @@ -22,6 +22,11 @@ resources/fanart.jpg +v3.0.18 +Fixed Highlights (again). +Fixed BBCiD login. +Made Added and Watching more robust against some changes. + v3.0.17 Fixed Highlights. diff --git a/plugin.video.iplayerwww/resources/lib/ipwww_common.py b/plugin.video.iplayerwww/resources/lib/ipwww_common.py index 962a169..56f4c0b 100644 --- a/plugin.video.iplayerwww/resources/lib/ipwww_common.py +++ b/plugin.video.iplayerwww/resources/lib/ipwww_common.py @@ -171,7 +171,7 @@ def SignInBBCiD(): 'attempts':'0'} #Regular expression to get 'nonce' from login page - p = re.compile('form method="post" action="([^""]*)"') + p = re.compile('action="([^""]*)"') with requests.Session() as s: resp = s.get('https://www.bbc.com/', headers=headers) diff --git a/plugin.video.iplayerwww/resources/lib/ipwww_video.py b/plugin.video.iplayerwww/resources/lib/ipwww_video.py index 08b6a0c..9af725b 100644 --- a/plugin.video.iplayerwww/resources/lib/ipwww_video.py +++ b/plugin.video.iplayerwww/resources/lib/ipwww_video.py @@ -671,7 +671,11 @@ def ScrapeMarkup(markup): r'', li, flags=(re.DOTALL | re.MULTILINE)) if url_match: - main_url = url_match.group(1) + tmp_url = url_match.group(1) + if tmp_url.startswith('http'): + main_url = tmp_url + else: + main_url = 'https://www.bbc.co.uk' + tmp_url name = '' title = '' @@ -725,7 +729,11 @@ def ScrapeMarkup(markup): r'27 @@ -1152,18 +1160,20 @@ def ListMainHighlights(highlights_url): if group_type == "trailers": continue - inner_anchors = re.findall(r'', group, flags=(re.DOTALL | re.MULTILINE)) + + group_data = [] for programme in inner_anchors: is_group = False - button_match = re.search(r'button', programme, flags=(re.DOTALL | re.MULTILINE)) + button_match = re.search(r'View all', programme, flags=(re.DOTALL | re.MULTILINE)) if button_match: is_group = True url = '' href_match = re.match( - r'(.*?)', + r'item__title.+?>(.*?)', programme, flags=(re.DOTALL | re.MULTILINE)) if name_match: name = name_match.group(1) - subtitle_match = re.search( - r'

(.*?)

', programme, flags=(re.DOTALL | re.MULTILINE)) + else: + subtitle_match = re.search( + r'primary">.*?item__description.+?>(.*?)', + programme, flags=(re.DOTALL | re.MULTILINE)) if subtitle_match: name = name + ' - ' + subtitle_match.group(1) iconimage = '' iconimage_match = re.search( - r'320x180/(.*?)\.jpg', programme, flags=(re.DOTALL | re.MULTILINE)) + r'images/ic/.*?/(.*?)\.jpg', programme, flags=(re.DOTALL | re.MULTILINE)) if iconimage_match: - iconimage = "http://ichef.bbci.co.uk/images/ic/832x468/"+iconimage_match.group(1)+".jpg" + iconimage = "https://ichef.bbci.co.uk/images/ic/832x468/"+iconimage_match.group(1)+".jpg" description = '' description_match = re.search( - r'

.*?item__description.+?>(.*?)', programme, flags=(re.DOTALL | re.MULTILINE)) if description_match: description = description_match.group(1) @@ -1212,15 +1227,20 @@ def ListMainHighlights(highlights_url): category = '' category_match = re.search(r'categories/(.*?)/', href, flags=re.DOTALL) if category_match: - AddMenuEntry('[B]%s: %s[/B]' % (translation(30314), name), - category_match.group(1), 125, '', '', '') + group_data.append(('[B]%s: %s[/B]' % (translation(30314), name), + category_match.group(1), 125)) else: - AddMenuEntry('[B]%s: %s[/B]' % (translation(30314), name), - url, 128, '', '', '') - + group_data.append(('[B]%s: %s[/B]' % (translation(30314), name), + url, 128)) else: CheckAutoplay(name, url, iconimage, description, '') + # For whatever reason, all groups appear twice in HTML, but we only want to add unique groups. + unique = [] + [unique.append(item) for item in group_data if item not in unique] + for name, url, mode in unique: + AddMenuEntry(name, url, mode, '', '', '') + xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) -- cgit v1.2.3