From b553865ff5bcd16b75b5bfbd570d85aaa6f2d57c Mon Sep 17 00:00:00 2001 From: TPD94 Date: Mon, 6 Oct 2025 16:49:41 -0400 Subject: [PATCH] 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 --- CR/__init__.py | 96 ++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/CR/__init__.py b/CR/__init__.py index 1b328a2..2e05b43 100644 --- a/CR/__init__.py +++ b/CR/__init__.py @@ -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