Skip to content

Commit

Permalink
Merge development into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jan 1, 2025
2 parents 6ec304d + 0413dba commit 6e43690
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
6 changes: 3 additions & 3 deletions bazarr/app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def configure_server(self):
threads=100)
self.connected = True
except OSError as error:
if error.errno == 49:
if error.errno == errno.EADDRNOTAVAIL:
logging.exception("BAZARR cannot bind to specified IP, trying with 0.0.0.0")
self.address = '0.0.0.0'
self.connected = False
super(Server, self).__init__()
elif error.errno == 48:
elif error.errno == errno.EADDRINUSE:
if self.port != '6767':
logging.exception("BAZARR cannot bind to specified TCP port, trying with default (6767)")
self.port = '6767'
Expand All @@ -64,7 +64,7 @@ def configure_server(self):
logging.exception("BAZARR cannot bind to default TCP port (6767) because it's already in use, "
"exiting...")
self.shutdown(EXIT_PORT_ALREADY_IN_USE_ERROR)
elif error.errno == 97:
elif error.errno == errno.ENOLINK:
logging.exception("BAZARR cannot bind to IPv6 (*), trying with 0.0.0.0")
self.address = '0.0.0.0'
self.connected = False
Expand Down
16 changes: 8 additions & 8 deletions bazarr/radarr/sync/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def update_movie(updated_movie, send_event):
updated_movie['updated_at_timestamp'] = datetime.now()
database.execute(
update(TableMovies).values(updated_movie)
.where(TableMovies.tmdbId == updated_movie['tmdbId']))
.where(TableMovies.radarrId == updated_movie['radarrId']))
except IntegrityError as e:
logging.error(f"BAZARR cannot update movie {updated_movie['path']} because of {e}")
else:
Expand All @@ -66,7 +66,7 @@ def update_movie(updated_movie, send_event):
def get_movie_monitored_status(movie_id):
existing_movie_monitored = database.execute(
select(TableMovies.monitored)
.where(TableMovies.tmdbId == str(movie_id)))\
.where(TableMovies.radarrId == str(movie_id)))\
.first()
if existing_movie_monitored is None:
return True
Expand Down Expand Up @@ -124,16 +124,16 @@ def update_movies(send_event=True):
return
else:
# Get current movies in DB
current_movies_id_db = [x.tmdbId for x in
current_movies_id_db = [x.radarrId for x in
database.execute(
select(TableMovies.tmdbId))
select(TableMovies.radarrId))
.all()]
current_movies_db_kv = [x.items() for x in [y._asdict()['TableMovies'].__dict__ for y in
database.execute(
select(TableMovies))
.all()]]

current_movies_radarr = [str(movie['tmdbId']) for movie in movies if movie['hasFile'] and
current_movies_radarr = [movie['id'] for movie in movies if movie['hasFile'] and
'movieFile' in movie and
(movie['movieFile']['size'] > MINIMUM_VIDEO_SIZE or
get_movie_file_size_from_db(movie['movieFile']['path']) > MINIMUM_VIDEO_SIZE)]
Expand All @@ -143,7 +143,7 @@ def update_movies(send_event=True):
movies_deleted = []
if len(movies_to_delete):
try:
database.execute(delete(TableMovies).where(TableMovies.tmdbId.in_(movies_to_delete)))
database.execute(delete(TableMovies).where(TableMovies.radarrId.in_(movies_to_delete)))
except IntegrityError as e:
logging.error(f"BAZARR cannot delete movies because of {e}")
else:
Expand Down Expand Up @@ -172,7 +172,7 @@ def update_movies(send_event=True):
if movie['hasFile'] is True:
if 'movieFile' in movie:
if sync_monitored:
if get_movie_monitored_status(movie['tmdbId']) != movie['monitored']:
if get_movie_monitored_status(movie['id']) != movie['monitored']:
# monitored status is not the same as our DB
trace(f"{i}: (Monitor Status Mismatch) {movie['title']}")
elif not movie['monitored']:
Expand All @@ -184,7 +184,7 @@ def update_movies(send_event=True):
get_movie_file_size_from_db(movie['movieFile']['path']) > MINIMUM_VIDEO_SIZE):
# Add/update movies from Radarr that have a movie file to current movies list
trace(f"{i}: (Processing) {movie['title']}")
if str(movie['tmdbId']) in current_movies_id_db:
if movie['id'] in current_movies_id_db:
parsed_movie = movieParser(movie, action='update',
tags_dict=tagsDict,
language_profiles=language_profiles,
Expand Down
4 changes: 2 additions & 2 deletions bazarr/sonarr/sync/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_language_profiles():

def get_series_monitored_table():
series_monitored = database.execute(
select(TableShows.tvdbId, TableShows.monitored))\
select(TableShows.sonarrSeriesId, TableShows.monitored))\
.all()
series_dict = dict((x, y) for x, y in series_monitored)
return series_dict
Expand Down Expand Up @@ -95,7 +95,7 @@ def update_series(send_event=True):

if sync_monitored:
try:
monitored_status_db = bool_map[series_monitored[show['tvdbId']]]
monitored_status_db = bool_map[series_monitored[show['id']]]
except KeyError:
monitored_status_db = None
if monitored_status_db is None:
Expand Down
6 changes: 4 additions & 2 deletions bazarr/utilities/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ def get_health_issues():
.where(TableShows.profileId.is_not(None))).scalar()
movies_with_profile = database.execute(select(func.count(TableMovies.radarrId))
.where(TableMovies.profileId.is_not(None))).scalar()
default_series_profile_empty = settings.general.serie_default_enabled and settings.general.serie_default_profile == ''
default_movies_profile_empty = settings.general.movie_default_enabled and settings.general.movie_default_profile == ''
if languages_profiles_count == 0:
health_issues.append({'object': 'Missing languages profile',
'issue': 'You must create at least one languages profile and assign it to your content.'})
elif languages_profiles_count > 0 and ((settings.general.use_sonarr and series_with_profile == 0) or
(settings.general.use_radarr and movies_with_profile == 0)):
elif languages_profiles_count > 0 and ((settings.general.use_sonarr and series_with_profile == 0 and default_series_profile_empty) or
(settings.general.use_radarr and movies_with_profile == 0 and default_movies_profile_empty)):
health_issues.append({'object': 'No assigned languages profile',
'issue': 'Although you have created at least one languages profile, you must assign it '
'to your content.'})
Expand Down
10 changes: 7 additions & 3 deletions custom_libs/subliminal_patch/providers/opensubtitlescom.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def search_titles(self, title):
if not title_id:
logger.debug(f'No match found for {title}')

@staticmethod
def is_real_forced(attributes):
return attributes['foreign_parts_only'] and not attributes['hearing_impaired']

def query(self, languages, video):
self.video = video
if self.use_hash:
Expand Down Expand Up @@ -363,11 +367,11 @@ def query(self, languages, video):

# filter out forced subtitles or not depending on the required languages
if all([lang.forced for lang in languages]): # only forced
result['data'] = [x for x in result['data'] if x['attributes']['foreign_parts_only']]
result['data'] = [x for x in result['data'] if self.is_real_forced(x['attributes'])]
elif any([lang.forced for lang in languages]): # also forced
pass
else: # not forced
result['data'] = [x for x in result['data'] if not x['attributes']['foreign_parts_only']]
result['data'] = [x for x in result['data'] if not self.is_real_forced(x['attributes'])]

logger.debug(f"Query returned {len(result['data'])} subtitles")

Expand Down Expand Up @@ -407,7 +411,7 @@ def query(self, languages, video):
if len(item['attributes']['files']):
subtitle = OpenSubtitlesComSubtitle(
language=Language.fromietf(from_opensubtitlescom(item['attributes']['language'])),
forced=item['attributes']['foreign_parts_only'],
forced=self.is_real_forced(item['attributes']),
hearing_impaired=item['attributes']['hearing_impaired'],
page_link=item['attributes']['url'],
file_id=item['attributes']['files'][0]['file_id'],
Expand Down

0 comments on commit 6e43690

Please sign in to comment.