Some more logging
parent
2359cf8cac
commit
c3568fccc2
|
@ -38,7 +38,12 @@ class BaseAnime():
|
|||
self._episodeIds = []
|
||||
r = requests.get(self.url)
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
return self._getEpisodeUrls(soup)
|
||||
self._episodeIds = self._getEpisodeUrls(soup)
|
||||
|
||||
logging.debug('EPISODE IDS: length: {}, ids: {}'.format(
|
||||
len(self._episodeIds), self._episodeIds))
|
||||
|
||||
return self._episodeIds
|
||||
|
||||
def __len__(self):
|
||||
return len(self._episodeIds)
|
||||
|
@ -78,10 +83,16 @@ class BaseEpisode:
|
|||
downloaded, chunksize = 0, 16384
|
||||
start_time = time.time()
|
||||
|
||||
logging.debug(path)
|
||||
|
||||
if os.path.exists(path) and not force:
|
||||
if os.stat(path).st_size == total_size:
|
||||
logging.warning('File already downloaded. Skipping download.')
|
||||
return
|
||||
else:
|
||||
os.remove(path)
|
||||
else:
|
||||
os.remove(path)
|
||||
|
||||
if r.status_code == 200:
|
||||
with open(path, 'wb') as f:
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
from .anime import BaseAnime, BaseEpisode
|
||||
from .exceptions import AnimeDLError, URLError, NotFoundError
|
||||
|
||||
|
||||
import json
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
__all__ = ['NineAnimeEpisode', 'NineAnime']
|
||||
|
||||
|
@ -19,13 +23,20 @@ class NineAnimeEpisode(BaseEpisode):
|
|||
params = {
|
||||
'id': self.episode_id,
|
||||
'server': '33',
|
||||
# 'update': 0,
|
||||
'ts': self.ts
|
||||
}
|
||||
params['param_'] = int(generate_(params))
|
||||
|
||||
logging.debug('API call params: {}'.format(params))
|
||||
|
||||
url = self._base_url.format(**params)
|
||||
|
||||
logging.debug('API call URL: {}'.format(url))
|
||||
|
||||
data = json.loads(requests.get(url).text)
|
||||
|
||||
logging.debug('Returned data: {}'.format(data))
|
||||
|
||||
url = data['target']
|
||||
title_re = re.compile(r'"og:title" content="(.*)"')
|
||||
image_re = re.compile(r'"og:image" content="(.*)"')
|
||||
|
@ -48,19 +59,25 @@ class NineAnime(BaseAnime):
|
|||
def _getEpisodeUrls(self, soup):
|
||||
ts = soup.find('html')['data-ts']
|
||||
self._episodeClass.ts = ts
|
||||
logging.debug('data-ts: {}'.format(ts))
|
||||
|
||||
episodes = soup.find_all('ul', ['episodes'])
|
||||
|
||||
if episodes == []:
|
||||
err = 'No episodes found in url "{}"'.format(self.url)
|
||||
if self._callback:
|
||||
self._callback(err)
|
||||
args = [self.url]
|
||||
raise NotFoundError(err, *args)
|
||||
|
||||
episodes = episodes[:int(len(episodes)/3)]
|
||||
|
||||
episode_ids = []
|
||||
|
||||
for x in episodes:
|
||||
for a in x.find_all('a'):
|
||||
ep_id = a.get('data-id')
|
||||
self._episodeIds.append(ep_id)
|
||||
episode_ids.append(ep_id)
|
||||
|
||||
return episode_ids
|
||||
|
||||
|
||||
def s(t):
|
||||
|
|
Loading…
Reference in New Issue