Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Improvement
Browse files Browse the repository at this point in the history
Trying to reduce errors as much as possible
  • Loading branch information
TechShreyash committed Nov 12, 2022
1 parent 6c64fcb commit 4e46f67
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 36 deletions.
53 changes: 35 additions & 18 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
app = Flask(__name__)


@app.errorhandler(404)
def error():
return 'Something went wrong...\n\n Probably Anilist Is Down. Report To https://t.me/techshreyash'
@app.errorhandler(Exception)
def error(error=None):
return '<h1>Something went wrong...\n\n Report To <a href="https://t.me/techshreyash">Owner</a></h1>'


@app.route('/')
Expand Down Expand Up @@ -111,21 +111,38 @@ def get_anime(anime):
typo = data.get('type')
status = data.get('status')
except:
data = GOGO.anime(x)
title = data[0]
synopsis = data[1]
names = data[2]
studios = data[3]
episodes = data[4]
genres = get_genre_html(data[5])
img = data[6]
dub = data[7]
season = data[8]
year = data[9]
typo = data[10]
status = data[11]
displayAnime = 'Not Available'
ep_html = get_eps_html(anime, title, episodes)
try:
data = GOGO.anime(x)
title = data[0]
synopsis = data[1]
names = data[2]
studios = data[3]
episodes = data[4]
genres = get_genre_html(data[5])
img = data[6]
dub = data[7]
season = data[8]
year = data[9]
typo = data[10]
status = data[11]
displayAnime = 'Not Available'
ep_html = get_eps_html(anime, title, episodes)
except:
data = GOGO.anime_api(x)
img = data.get('image')
title = data.get('title')
synopsis = data.get('description')
names = data.get('otherName')
studios = '?'
episodes = str(len(data.get('episodes')))
genres = get_genre_html(data.get('genres'))
displayAnime = 'Not Available'
ep_html = get_eps_html(anime, title)
dub = data.get('subOrDub').upper()
season = data.get('type')
year = data.get('type')
typo = data.get('type')
status = data.get('status')

html = render_template('anime.html',
img=img,
Expand Down
53 changes: 35 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
app = Flask(__name__)


@app.errorhandler(404)
def error():
return 'Something went wrong...\n\n Probably Anilist Is Down. Report To https://t.me/techshreyash'
@app.errorhandler(Exception)
def error(error=None):
return '<h1>Something went wrong...\n\n Report To <a href="https://t.me/techshreyash">Owner</a></h1>'


@app.route('/')
Expand Down Expand Up @@ -111,21 +111,38 @@ def get_anime(anime):
typo = data.get('type')
status = data.get('status')
except:
data = GOGO.anime(x)
title = data[0]
synopsis = data[1]
names = data[2]
studios = data[3]
episodes = data[4]
genres = get_genre_html(data[5])
img = data[6]
dub = data[7]
season = data[8]
year = data[9]
typo = data[10]
status = data[11]
displayAnime = 'Not Available'
ep_html = get_eps_html(anime, title, episodes)
try:
data = GOGO.anime(x)
title = data[0]
synopsis = data[1]
names = data[2]
studios = data[3]
episodes = data[4]
genres = get_genre_html(data[5])
img = data[6]
dub = data[7]
season = data[8]
year = data[9]
typo = data[10]
status = data[11]
displayAnime = 'Not Available'
ep_html = get_eps_html(anime, title, episodes)
except:
data = GOGO.anime_api(x)
img = data.get('image')
title = data.get('title')
synopsis = data.get('description')
names = data.get('otherName')
studios = '?'
episodes = str(len(data.get('episodes')))
genres = get_genre_html(data.get('genres'))
displayAnime = 'Not Available'
ep_html = get_eps_html(anime, title)
dub = data.get('subOrDub').upper()
season = data.get('type')
year = data.get('type')
typo = data.get('type')
status = data.get('status')

html = render_template('anime.html',
img=img,
Expand Down
17 changes: 17 additions & 0 deletions programs/gogo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests
from bs4 import BeautifulSoup as bs
from programs.others import get_t_from_u
from programs.vidstream import extract


Expand All @@ -15,6 +16,8 @@ def __init__(self, url, img, lang, title, episode) -> None:
class GoGoApi:
def __init__(self) -> None:
self.host = 'gogoanime.dk'
self.api = ['https://api-techshreyash.up.railway.app/',
'https://api.consumet.org/']

def search(self, query, url_only=False):
soup = bs(requests.get(
Expand All @@ -40,6 +43,20 @@ def search(self, query, url_only=False):
)
return results

def anime_api(self, anime):
anime = get_t_from_u(anime).strip().replace(' ', '-')
for host in self.api:
try:
url = host + 'anime/gogoanime/info/' + anime
data = requests.get(url)
if data.status_code == 200:
data = data.json()
if data:
break
except:
continue
return data

def anime(self, anime):
soup = bs(requests.get(
f'https://{self.host}/category/'+anime).content, 'html.parser')
Expand Down

1 comment on commit 4e46f67

@vercel
Copy link

@vercel vercel bot commented on 4e46f67 Nov 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anime-dex – ./

anime-dex-git-main-techshreyash.vercel.app
anime-dex-techshreyash.vercel.app
anime-dex1.vercel.app

Please sign in to comment.