summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-02-20 11:59:47 +0100
committeremkael <emkael@tlen.pl>2018-02-20 11:59:47 +0100
commitf5c15f61592454e75aec384592f5d0c7f9ff1b07 (patch)
tree6435f71428a5d14801eb02f4fc6294929724b17d /jfr_playoff
parent135253ceed4ec8cdbe8c5227700ac0a00e130e85 (diff)
Fetching running segment link from remote URL as a fallback to database
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/matchinfo.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py
index bd163af..5aa9d82 100644
--- a/jfr_playoff/matchinfo.py
+++ b/jfr_playoff/matchinfo.py
@@ -280,14 +280,26 @@ class MatchInfo:
return '%s%st%d-%d.html' % (
prefix, round_no, self.config['table'], current_segment)
+ def __get_html_running_link(self):
+ row = self.__find_table_row(self.info.link)
+ running_link = row.select('td.bdcg a[href]')
+ if len(running_link) == 0:
+ raise ValueError('running link not found')
+ return urljoin(self.info.link, running_link[0]['href'])
+
def __determine_running_link(self):
link_match = re.match(r'^(.*)runda(\d+)\.html$', self.info.link)
if link_match:
try:
+ if self.database is None:
+ raise KeyError('database not configured')
self.info.link = self.__get_db_running_link(
link_match.group(1), link_match.group(2))
except (mysql.connector.Error, TypeError, IndexError, KeyError):
- pass
+ try:
+ self.info.link = self.__get_html_running_link()
+ except (TypeError, IndexError, KeyError, IOError, ValueError):
+ pass
def set_phase_link(self, phase_link):
if self.info.link is None: