morpheus65535 / bazarr

Bazarr is a companion application to Sonarr and Radarr. It manages and downloads subtitles based on your requirements. You define your preferences by TV show or movie and Bazarr takes care of everything for you.
https://www.bazarr.media
GNU General Public License v3.0
2.84k stars 221 forks source link

Throttling legendasdivx for 10 minutes #2541

Closed modem closed 4 months ago

modem commented 4 months ago

Describe the bug Provider legendasdivx.com is throwing errors after movie subtitle search, either manual or automatic. I'm using the 1.4.4-beta.6 as downloading from this provider was not working on version 1.4.3 (bug https://github.com/morpheus65535/bazarr/issues/2509).

Haven't seen this error when searching for TV episode subtitles. Error mentions 'Movie' object has no attribute 'season' so the error should be specific to movies only. Probably the search URL is malformed.

To Reproduce Steps to reproduce the behavior:

  1. Enable legendasdivx.com provider
  2. Search for a movie subtitle
  3. Look at the error in the logs
  4. Check the provider gets disabled for 10 minutes with status error AttributeError

Expected behavior No errors expected

Screenshots image image

Software (please complete the following information):

Additional context Wondering if fix for https://github.com/morpheus65535/bazarr/issues/2509 was enough or if it introduced this new bug. Debug log:

2024-06-17 10:22:17|DEBUG   |root                            |BAZARR updating pool: movie_1|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Discarded providers: {'legendasdivx'} | New providers: {'embeddedsubtitles', 'legendasdivx'}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Updated discarded providers: set()|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Removed providers: set()|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |No provider config updates|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |This pool will use 2 threads from now on|
2024-06-17 10:22:17|DEBUG   |root                            |BAZARR pools update elapsed time: 34.88ms|
2024-06-17 10:22:17|DEBUG   |root                            |BAZARR Searching subtitles for this file: /media/Movies/The Amazing Maurice (2022)/The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |No provider config updates|
2024-06-17 10:22:17|DEBUG   |subzero.video                   |Parsing video: The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv, hints: {'title': 'The Amazing Maurice', 'type': 'movie'}|
2024-06-17 10:22:17|INFO    |subliminal_patch.core           |Determining basic video properties for 'The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv' in '/media/Movies/The Amazing Maurice (2022)'|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |GuessIt found: {
    "subtitle_language": "und",
    "title": "The Amazing Maurice",
    "year": 2022,
    "screen_size": "1080p",
    "source": "Blu-ray",
    "video_codec": "H.264",
    "release_group": "OFT",
    "container": "mkv",
    "type": "movie"
}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Size is 4175678395|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Computed hashes {}|
2024-06-17 10:22:17|DEBUG   |root                            |Running refiner: database|
2024-06-17 10:22:17|DEBUG   |root                            |Running refiner: ffprobe|
2024-06-17 10:22:17|DEBUG   |root                            |FFprobe found: {'title': 'The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT', 'path': '/media/Movies/The Amazing Maurice (2022)/The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv', 'duration': datetime.timedelta(seconds=5381, microseconds=5000), 'size': 4175678395, 'bit_rate': 6208027, 'container': 'mkv', 'video': [{'id': 0, 'duration': datetime.timedelta(seconds=5381), 'width': 1920, 'height': 1080, 'scan_type': 'Progressive', 'aspect_ratio': Decimal('1.778'), 'pixel_aspect_ratio': Decimal('1.0'), 'resolution': '1080p', 'frame_rate': Decimal('25.0'), 'bit_rate': 5757999, 'bit_depth': 8, 'codec': 'H.264', 'profile': 'High', 'default': True}], 'audio': [{'id': 1, 'name': 'Surround', 'language': <Language [en]>, 'duration': datetime.timedelta(seconds=5380, microseconds=992000), 'codec': 'AC-3', 'channels_count': 6, 'channels': '5.1', 'bit_rate': 448000, 'sampling_rate': 48000, 'default': True}], 'subtitle': [{'id': 2, 'name': 'English SDH', 'language': <Language [en]>, 'format': 'SubRip', 'hearing_impaired': True}], 'provider': {'name': 'ffmpeg', 'version': {'/usr/bin/ffprobe': 'v6.0.1'}}}|
2024-06-17 10:22:17|DEBUG   |root                            |Running refiner: arr_history|
2024-06-17 10:22:17|DEBUG   |root                            |Running refiner: anidb|
2024-06-17 10:22:17|DEBUG   |root                            |Video is not an Anime TV series, skipping refinement for <Movie ['The Amazing Maurice', 2022]>|
2024-06-17 10:22:17|DEBUG   |root                            |BAZARR is using these video object properties: {'name': '/media/Movies/The Amazing Maurice (2022)/The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv', 'source': 'Blu-ray', 'release_group': 'OFT', 'resolution': '1080p', 'video_codec': 'H.264', 'audio_codec': 'Dolby Digital', 'imdb_id': 'tt10473036', 'hashes': {}, 'size': 4175678395, 'subtitle_languages': set(), 'original_name': 'The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv', 'plexapi_metadata': {}, 'hints': {'title': 'The Amazing Maurice', 'type': 'movie', 'single_value': True}, 'audio_languages': {'eng'}, 'external_subtitle_languages': set(), 'streaming_service': None, 'edition': None, 'original_path': '/media/Movies/The Amazing Maurice (2022)/The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv', 'other': None, 'info_url': None, 'series_anidb_series_id': (None,), 'series_anidb_episode_id': (None,), 'title': 'The Amazing Maurice', 'year': 2022, 'alternative_titles': ['The Amazing Maurice and His Educated Rodents', 'Magiske Maurits og hans gløgge gnagere', 'Brīnumainā Morisa dēkas', 'Mageløse Maurice og hans rådsnare rotte', 'Mahtava Morris', 'El asombroso Mauricio', '喵的詐騙集團'], 'used_scene_name': False, 'radarrId': 293, 'fps': Decimal('25.0')}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.score          |Hash value: 119 -> Rest sum: 120|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.score          |Hash value: 359 -> Rest sum: 360|
2024-06-17 10:22:17|INFO    |subliminal_patch.core_persistent|Downloading best subtitles for <Movie ['The Amazing Maurice', 2022]>|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Languages requested: {<Language: alpha3=por>}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Languages requested: {<Language: alpha3=por>}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |New set: 744 items|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |New set: 2 items|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Nothing to translate found|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.core           |Nothing to translate found|
2024-06-17 10:22:17|INFO    |subliminal_patch.core           |Listing subtitles with provider 'embeddedsubtitles' and languages {<Language: alpha3=por>}|
2024-06-17 10:22:17|INFO    |subliminal_patch.core           |Listing subtitles with provider 'legendasdivx' and languages {<Language: alpha3=por>}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.embeddedsubtitles|Rebuild language: <Language: hi=True;alpha3=eng>|
2024-06-17 10:22:17|INFO    |subliminal_patch.core           |Initializing provider legendasdivx|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.embeddedsubtitles|Checking possible incomplete subtitles (max frames: 1561)|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.legendasdivx|Legendasdivx.pt :: Creating session for requests|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.embeddedsubtitles|<Language: hi=True;alpha3=eng> not in {<Language: alpha3=por>}|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.embeddedsubtitles|Cache info: CacheInfo(hits=40, misses=37, maxsize=8096, currsize=37)|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.legendasdivx|Legendasdivx.pt :: Re-using previous legendasdivx cookies: <RequestsCookieJar[<Cookie phpbb3_2z8zs_u=<removed> for .legendasdivx.pt/>, <Cookie phpbb3_2z8zs_k= for .legendasdivx.pt/>, <Cookie phpbb3_2z8zs_sid=<removed> for .legendasdivx.pt/>, <Cookie PHPSESSID=<removed> for .legendasdivx.pt/>, <Cookie lang=portuguese for www.legendasdivx.pt/>]>|
2024-06-17 10:22:17|DEBUG   |subliminal_patch.providers.legendasdivx|Legendasdivx.pt :: searching for pt subtitles.|
2024-06-17 10:22:17|ERROR   |subliminal_patch.core           |Unexpected error in provider 'legendasdivx': Traceback (most recent call last):  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/core.py", line 368, in list_subtitles_provider    results = self[provider].list_subtitles(video, to_request)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/providers/legendasdivx.py", line 444, in list_subtitles    return self.query(video, languages)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/providers/__init__.py", line 47, in wrapper    return method(self, *args, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/providers/legendasdivx.py", line 328, in query    season=video.season,           ^^^^^^^^^^^^AttributeError: 'Movie' object has no attribute 'season'|Traceback (most recent call last):  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/core.py", line 368, in list_subtitles_provider    results = self[provider].list_subtitles(video, to_request)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/providers/legendasdivx.py", line 444, in list_subtitles    return self.query(video, languages)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/providers/__init__.py", line 47, in wrapper    return method(self, *args, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/app/bazarr/bin/bazarr/../custom_libs/subliminal_patch/providers/legendasdivx.py", line 328, in query    season=video.season,           ^^^^^^^^^^^^AttributeError: 'Movie' object has no attribute 'season'|
2024-06-17 10:22:17|INFO    |root                            |Throttling legendasdivx for 10 minutes, until 24/06/17 10:32, because of: AttributeError. Exception info: "''Movie' object has no attribute 'season'' ~ legendasdivx.py@328"|
2024-06-17 10:22:17|INFO    |socketio.server                 |emitting event "data" to all [/]|
2024-06-17 10:22:17|INFO    |engineio.server                 |TpbV2oH0K_VluGqoAAAK: Sending packet MESSAGE data 2["data",{"type":"badges","action":"update","payload":null}]|
2024-06-17 10:22:17|INFO    |subliminal_patch.core           |Discarding provider legendasdivx|
2024-06-17 10:22:17|INFO    |subliminal_patch.core_persistent|Downloaded 0 subtitle(s)|
2024-06-17 10:22:17|DEBUG   |root                            |BAZARR No Subtitles were found for this file: /media/Movies/The Amazing Maurice (2022)/The.Amazing.Maurice.2022.1080p.BluRay.x264-OFT.mkv|
modem commented 4 months ago

Looking at the last code modification, there are 2 possible places that seem related to this issue. 1st is the search URL:

image

the 2nd is populating the search URL: image

There is no distinction if the search is for a movie of for an episode, so when trying to get the season from a movie it fails as movies have no seasons. I tested searching for a movie subtitle leaving temporada and episodio empty (for season and episode respectively) and the search returns correct results (in the browser).

Used the following test url: https://www.legendasdivx.pt/modules.php?name=Downloads&file=jz&d_op=search&op=_jz00&query=tt10473036&temporada=&episodio=&imdb=tt10473036

query and imdb in this case both show the imdb_id, as further above in the code, query is set to the imdb_id if available, otherwise it is set to movie title.

It also works without the imdb tag in the URL, or leaving it empty.

modem commented 4 months ago

Submitted a pull request with a dirty fix,

morpheus65535 commented 4 months ago

Should be fixed by your PR in upcoming beta.