Skip to content

Commit

Permalink
fixes content not displaying on mobile variants
Browse files Browse the repository at this point in the history
  • Loading branch information
SageTendo committed Feb 12, 2024
1 parent 133d821 commit 852ec42
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 136 deletions.
4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cryptography = "*"
distlib = "*"
dnspython = "*"
filelock = "*"
flask = "*"
flask = {extras = ["async"], version = "*"}
greenlet = "*"
html5lib = "*"
idna = "*"
Expand Down Expand Up @@ -60,8 +60,10 @@ zipp = "*"
pymongo = {extras = ["srv"], version = "*"}
waitress = "*"
flask-session = "*"
flask-compress = "*"

[dev-packages]
uvicorn = "*"

[requires]
python_version = "3.9"
403 changes: 276 additions & 127 deletions Pipfile.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/routes/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def mal_to_meta(anime_item: dict):
media_type = None

return {
'cacheMaxAge': 43200,
'staleRevalidate': 3600,
'staleError': 3600,
'id': formatted_content_id,
'name': title,
'type': media_type,
Expand Down
15 changes: 8 additions & 7 deletions app/routes/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@

MANIFEST = {
'id': 'com.sagetendo.mal-stremio-addon',
'version': '1.1.1',
'version': '1.2.0',
'name': 'MAL-Stremio Addon',
'logo': 'https://i.imgur.com/zVYdffr.png',
'description': 'Provides users with watchlist content from MyAnimeList within Stremio. '
'This addon only provides catalogs, with the help of AnimeKitsu',
'types': ['anime', 'series', 'movie'],

'catalogs': [
{'type': 'anime', 'id': 'plan_to_watch', 'name': 'MAL: Plan To Watch'},
{'type': 'anime', 'id': 'watching', 'name': 'MAL: Watching'},
{'type': 'anime', 'id': 'completed', 'name': 'MAL: Completed'},
{'type': 'anime', 'id': 'on_hold', 'name': 'MAL: On Hold'},
{'type': 'anime', 'id': 'dropped', 'name': 'MAL: Dropped'},
{'type': 'anime', 'id': 'plan_to_watch', 'name': 'MAL: Plan To Watch', 'extra': [{'name': 'skip'}]},
{'type': 'anime', 'id': 'watching', 'name': 'MAL: Watching', 'extra': [{'name': 'skip'}]},
{'type': 'anime', 'id': 'completed', 'name': 'MAL: Completed', 'extra': [{'name': 'skip'}]},
{'type': 'anime', 'id': 'on_hold', 'name': 'MAL: On Hold', 'extra': [{'name': 'skip'}]},
{'type': 'anime', 'id': 'dropped', 'name': 'MAL: Dropped', 'extra': [{'name': 'skip'}]},
{
'type': 'anime',
'id': 'search_list',
'name': 'Search Results',
'extra': [
{'name': 'search', 'isRequired': True}
{'name': 'search', 'isRequired': True},
{'name': 'skip'}
]
}
],
Expand Down
48 changes: 47 additions & 1 deletion app/routes/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,50 @@ def addon_meta(user_id: str, meta_type: str, meta_id: str):
logging.error(resp.status_code, resp.reason)
abort(404, f"{resp.status_code}: {resp.reason}")

return respond_with(resp.json()) # Return with CORS to client
meta = kitsu_to_meta(resp.json())
meta['id'] = meta_id
meta['type'] = meta_type
return respond_with({'meta': meta}) # Return with CORS to client


def kitsu_to_meta(kitsu_meta: dict):
"""
Convert kitsu item to a valid Stremio meta format
:param kitsu_meta: The kitsu item to convert
:return: Stremio meta format
"""
meta = kitsu_meta.get('meta', {})

name = meta.get('name', '')
genres = meta.get('genres', [])
logo = meta.get('logo', None)
poster = meta.get('poster', None)
background = meta.get('background', None)
description = meta.get('description', None)
releaseInfo = meta.get('releaseInfo', None)
year = meta.get('year', None)
imdbRating = meta.get('imdbRating', None)
trailers = meta.get('trailers', [])
links = meta.get('links', [])
cacheMaxAge = meta.get('cacheMaxAge', None)
runtime = meta.get('runtime', None)
videos = meta.get('videos', [])

return {
'cacheMaxAge': cacheMaxAge,
'staleRevalidate': 43200,
'staleError': 3600,
'name': name,
'genres': genres,
'logo': logo,
'poster': poster,
'background': background,
'description': description,
'releaseInfo': releaseInfo,
'year': year,
'imdbRating': imdbRating,
'trailers': trailers,
'links': links,
'runtime': runtime,
'videos': videos
}
3 changes: 3 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from flask import Flask, render_template, session
from flask_compress import Compress
from flask_session import Session

from app.db.db import db
Expand All @@ -19,6 +20,8 @@

app.config['SESSION_MONGODB'] = db
Session(app)
Compress(app)

logging.basicConfig(format='%(asctime)s %(message)s')


Expand Down

0 comments on commit 852ec42

Please sign in to comment.