1.0.4 release

- Update version number
- Added check for `skip-event` AKA chapters endpoint for 200 (OK) status code before attempting to get chapters, if not 200, return empty chapters
This commit is contained in:
TPD94 2025-10-06 16:49:41 -04:00
parent c4ceb2fe92
commit b553865ff5

View File

@ -25,7 +25,7 @@ class CR(Service):
"""
Service code for Crunchyroll
Author: TPD94
Version: 1.0.3
Version: 1.0.4
Authorization: Cookies for web endpoints, Credentials for TV endpoints, Cookies/Credentials for both. Cookies required.
Security: FHD@L3
Use Series ID/URL (for example - https://www.crunchyroll.com/series/GG5H5XQ7D/kaiju-no-8) or Series ID (for example - GG5H5XQ7D).
@ -36,7 +36,7 @@ class CR(Service):
help="""
Service code for Crunchyroll\n
Author: TPD94\n
Version: 1.0.3\n
Version: 1.0.4\n
Authorization: Cookies for web endpoints, Credentials for TV endpoints, Cookies/Credentials for both. Cookies required.\n
Security: FHD@L3\n
Use Series ID/URL (for example - https://www.crunchyroll.com/series/GG5H5XQ7D/kaiju-no-8) or Series ID (for example - GG5H5XQ7D).
@ -542,55 +542,57 @@ class CR(Service):
# Send GET request for the chapters
chapter_response = self.session.get(
url=self.config['endpoints']['chapters'].format(episode=title.id),
).json()
)
# Check for intro chapter
if chapter_response.get('intro'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['intro']['start'] * 1000,
name=chapter_response['intro']['type'].capitalize(),
))
# If it doesn't exist, move on to the next
except:
pass
if chapter_response.status_code == 200:
chapter_response = chapter_response.json()
# Check for intro chapter
if chapter_response.get('intro'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['intro']['start'] * 1000,
name=chapter_response['intro']['type'].capitalize(),
))
# If it doesn't exist, move on to the next
except:
pass
# Check for the credits chapter
if chapter_response.get('credits'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['credits']['start'] * 1000,
name=chapter_response['credits']['type'].capitalize(),
))
# If it doesn't exist, move on to the next
except:
pass
# Check for the credits chapter
if chapter_response.get('credits'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['credits']['start'] * 1000,
name=chapter_response['credits']['type'].capitalize(),
))
# If it doesn't exist, move on to the next
except:
pass
# Check for the preview chapter
if chapter_response.get('preview'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['preview']['start'] * 1000,
name=chapter_response['preview']['type'].capitalize(),
))
# If it doesn't exist, move on to the next
except:
pass
# Check for the preview chapter
if chapter_response.get('preview'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['preview']['start'] * 1000,
name=chapter_response['preview']['type'].capitalize(),
))
# If it doesn't exist, move on to the next
except:
pass
# Check for recap chapter
if chapter_response.get('recap'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['recap']['start'] * 1000,
name=chapter_response['recap']['type'].capitalize(),
))
# If it doesn't exist, move on to return statement
except:
pass
# Check for recap chapter
if chapter_response.get('recap'):
try:
# Add the chapter, may not exist
chapters.add(Chapter(
timestamp=chapter_response['recap']['start'] * 1000,
name=chapter_response['recap']['type'].capitalize(),
))
# If it doesn't exist, move on to return statement
except:
pass
# Return the chapters
return chapters