From 74f56d7bc529bd8ea6b9df68284032b523dc6f0a Mon Sep 17 00:00:00 2001 From: hbiyik Date: Sat, 26 Jun 2021 02:24:39 +0200 Subject: [PATCH] ghub: fix scraper --- script.module.ghub/addon.xml | 2 +- script.module.ghub/lib/ghub.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/script.module.ghub/addon.xml b/script.module.ghub/addon.xml index e0b1a8b..f300fdf 100755 --- a/script.module.ghub/addon.xml +++ b/script.module.ghub/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/script.module.ghub/lib/ghub.py b/script.module.ghub/lib/ghub.py index 62d7399..4020bb7 100755 --- a/script.module.ghub/lib/ghub.py +++ b/script.module.ghub/lib/ghub.py @@ -28,6 +28,7 @@ from six.moves.urllib import request from six import PY2 import xbmc +import traceback if PY2: @@ -64,11 +65,16 @@ def _getrels(uname, rname): rels = page.findall(".//div[@class='Box']/div/div/div/ul") allrels = [] for rel in rels: - links = rel.findall(".//a[@class='muted-link']") - commit = links[0].get("href").split("/")[-1] - zipu = links[1].get("href") - zipu = "https://" + _dom + zipu - allrels.append([commit, zipu]) + commit = None + zipu = None + for a in rel.findall(".//a"): + href = a.get("href") + if href and href.endswith(".zip"): + zipu = "https://" + _dom + href + if href and "/commit/" in href: + commit = href.split("/")[-1] + if zipu and commit: + allrels.append([commit, zipu]) return allrels @@ -125,6 +131,7 @@ def _load(uname, rname, branch, commit, path, period): ref = _getrels(uname, rname) except Exception: print("GITHUB: WARNING: Can not get latest meta: User:%s Repo:%s Branch:%s Commit: %s" % (uname, rname, branch, commit)) + print(traceback.format_exc()) return # download new package, extract and update the memory file