fix tapas episode list

This commit is contained in:
bakatrouble 2019-03-31 23:35:38 +03:00
parent a4ebacb80f
commit f00577060c

View File

@ -1,4 +1,6 @@
import json
import os import os
import re
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
import sentry_sdk import sentry_sdk
@ -24,22 +26,25 @@ class TapasFeedModuleConfig(FeedModuleConfig):
if last_id is None: if last_id is None:
last_id = 0 last_id = 0
soup = BeautifulSoup(requests.get( series_page = requests.get(
f'https://tapas.io/series/{self.display_name}', f'https://tapas.io/series/{self.display_name}',
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'}, headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'},
).text, 'html.parser') ).text
for episode in soup.select('#episode-nav .episode'): episode_list = json.loads(re.search(r'episodeList : (\[.*\]),', series_page).group(1))
eid = int(episode['data-eid']) for episode in episode_list:
eid = episode['id']
title = episode['title']
if eid <= last_id: if eid <= last_id:
continue continue
if not episode['free']:
continue
caption = f'{title}\nhttps://tapas.io/episode/{eid}'
esoup = BeautifulSoup(requests.get( esoup = BeautifulSoup(requests.get(
f'https://tapas.io/episode/{eid}', f'https://tapas.io/episode/{eid}',
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'}, headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'},
).text, 'html.parser') ).text, 'html.parser')
# series_title = esoup.select_one('#series-info-wrap a.series-header-title').text
title = esoup.select_one(f'#episodes [data-eid={eid}] h1').text
caption = f'{title}\nhttps://tapas.io/episode/{eid}'
imgs = [] imgs = []
for img in esoup.select(f'#episodes [data-eid={eid}] .art-image'): for img in esoup.select(f'#episodes [data-eid={eid}] .art-image'):
imgs.append(img['src']) imgs.append(img['src'])