Skip to content

Commit

Permalink
Fix for #32
Browse files Browse the repository at this point in the history
  • Loading branch information
Fribb committed Jan 8, 2022
1 parent dd493a5 commit 6bac1c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Contents/Code/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CommonUtils:
''' caching time for requests '''
AGENT_CACHE_TIME = CACHE_1HOUR * 24
''' mapping file '''
AGENT_MAPPING_URL = "https://fribbtastic.net/mapping/anime-list-full.json"
AGENT_MAPPING_URL = "https://raw.githubusercontent.com/Fribb/anime-lists/master/anime-list-full.json"
''' headers '''
AGENT_HEADERS = {'Content-type': 'application/json'}

Expand Down
12 changes: 11 additions & 1 deletion Contents/Code/utils/jikan.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from common import CommonUtils
import re
import time

class JikanApiUtils:

API_MAIN = "https://jikan.fribbtastic.net/v3"
API_MAIN = "https://api.jikan.moe/v3"
API_DETAILS = "/anime/{id}"
API_SEARCH = "/search/anime?q={title}"
API_EPISODES = API_DETAILS + "/episodes/{page}"
Expand Down Expand Up @@ -222,6 +223,9 @@ def getEpisodes(self, metadata):

# if there are more pages, parse them too and add them to the metadata
for currentPage in range(firstPage + 1, maxPages + 1):

## Wait 0.5 seconds to not go beyond the rate limit of the Jikan API
time.sleep(0.5)

nextPageUrl = self.API_MAIN + self.API_EPISODES.format(id=metadata.id,page=currentPage)
nextPageResult = JSON.ObjectFromString(self.COMMON_UTILS.getResponse(nextPageUrl))
Expand Down Expand Up @@ -271,6 +275,9 @@ def parseEpisodePage(self, metadata, current, max, page):
def getPictures(self, metadata):
Log.Info("[" + self.AGENT_NAME + "] " + "Requesting Pictures from Jikan")

## Wait 0.5 seconds to not go beyond the rate limit of the Jikan API
time.sleep(0.5)

picturesUrl = self.API_MAIN + self.API_PICTURES.format(id=metadata.id)
pictureResponse = self.COMMON_UTILS.getResponse(picturesUrl)

Expand Down Expand Up @@ -304,6 +311,9 @@ def getCharacters(self, metadata):
preferredVaLanguage = str(Prefs["actorLanguage"])
preferredCharacterImage = str(Prefs["actorImage"])

## Wait 0.5 seconds to not go beyond the rate limit of the Jikan API
time.sleep(0.5)

staffUrl = self.API_MAIN + self.API_STAFF.format(id=metadata.id)
staffResponse = self.COMMON_UTILS.getResponse(staffUrl)

Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu, 14 Oct 2021 18:22:27 +0200
#Sat, 08 Jan 2022 09:11:23 +0100
major.number=7
minor.number=0
build.number=2
build.number=3

0 comments on commit 6bac1c2

Please sign in to comment.