Skip to content

Commit f242a75

Browse files
committed
Make wikipedia heading handling dynamic
1 parent 1449d25 commit f242a75

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ordering/utils.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,20 @@ def get_episode_list(series_soup, series):
4040
for row in table.getText().split('\n\n') if row.strip()
4141
]
4242
else:
43+
table_heading = table.find(name='tr', class_=None)
44+
table_headings = [
45+
heading.getText().replace(' ', '').lower()
46+
for heading in table_heading.children
47+
]
48+
episode_num_index = table_headings.index('no.inseason')
49+
title_index = table_headings.index('title')
50+
air_date_index = table_headings.index('originalairdate')
51+
52+
wikipedia_row_unpacker = itemgetter(episode_num_index, title_index, air_date_index)
53+
4354
table = [
44-
[j.getText() for j in itemgetter(1, 3, 5, 11)(i.contents)]
45-
for i in table.find_all(class_='vevent')
55+
[episode_row_col.getText() for episode_row_col in wikipedia_row_unpacker(episode_row.contents)]
56+
for episode_row in table.find_all(class_='vevent')
4657
]
4758

4859
for row in table:

0 commit comments

Comments
 (0)