Add check for wrong urls
parent
b9cde4dfda
commit
65e9b5920c
|
@ -33,6 +33,10 @@ class Anime:
|
|||
r = requests.get(self.url)
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
episodes = soup.find_all('ul', ['episodes'])
|
||||
if episodes == []:
|
||||
err = 'No episodes found in url "{}"'.format(self.url)
|
||||
args = [self.url]
|
||||
raise NotFoundError(err, *args)
|
||||
episodes = episodes[:int(len(episodes)/3)]
|
||||
|
||||
for x in episodes:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import click
|
||||
from .anime import Anime
|
||||
from .anime import Anime, NotFoundError
|
||||
|
||||
echo = click.echo
|
||||
|
||||
|
@ -17,7 +17,11 @@ def cli(anime_url, range, playlist, url):
|
|||
|
||||
Download your favourite anime.
|
||||
"""
|
||||
anime = Anime(anime_url)
|
||||
try:
|
||||
anime = Anime(anime_url)
|
||||
except NotFoundError as e:
|
||||
echo(e.args[0])
|
||||
return
|
||||
|
||||
if range is None:
|
||||
range = '1:'+str(len(anime)+1)
|
||||
|
|
Loading…
Reference in New Issue