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 Oct 14, 2023
2 parents 823f3d8 + d657941 commit a09cc34
Show file tree
Hide file tree
Showing 31 changed files with 561 additions and 191 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Tools required

- Python 3.7.x to 3.10.x (3.9.x is highly recommended and 3.11 or greater is proscribed).
- Python 3.7.x to 3.11.x (3.9.x is highly recommended and 3.12 or greater is proscribed).
- Pycharm or Visual Studio code IDE are recommended but if you're happy with VIM, enjoy it!
- Git.
- UI testing must be done using Chrome latest version.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ If you need something that is not already part of Bazarr, feel free to create a
- Embedded Subtitles
- Gestdown.info
- GreekSubtitles
- HDBits.org
- Hosszupuska
- LegendasDivx
- Karagarga.in
Expand Down
4 changes: 4 additions & 0 deletions bazarr/api/episodes/episodes_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def patch(self):
title, 'series', profile_id=get_profile_id(episode_id=sonarrEpisodeId)))
if isinstance(result, list) and len(result):
result = result[0]
if isinstance(result, tuple) and len(result):
result = result[0]
history_log(1, sonarrSeriesId, sonarrEpisodeId, result)
send_notifications(sonarrSeriesId, sonarrEpisodeId, result.message)
store_subtitles(result.path, episodePath)
Expand Down Expand Up @@ -155,6 +157,8 @@ def post(self):
if not result:
logging.debug(f"BAZARR unable to process subtitles for this episode: {episodePath}")
else:
if isinstance(result, tuple) and len(result):
result = result[0]
provider = "manual"
score = 360
history_log(4, sonarrSeriesId, sonarrEpisodeId, result, fake_provider=provider, fake_score=score)
Expand Down
4 changes: 4 additions & 0 deletions bazarr/api/movies/movies_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def patch(self):
sceneName, title, 'movie', profile_id=get_profile_id(movie_id=radarrId)))
if isinstance(result, list) and len(result):
result = result[0]
if isinstance(result, tuple) and len(result):
result = result[0]
history_log_movie(1, radarrId, result)
store_subtitles_movie(result.path, moviePath)
else:
Expand Down Expand Up @@ -151,6 +153,8 @@ def post(self):
if not result:
logging.debug(f"BAZARR unable to process subtitles for this movie: {moviePath}")
else:
if isinstance(result, tuple) and len(result):
result = result[0]
provider = "manual"
score = 120
history_log_movie(4, radarrId, result, fake_provider=provider, fake_score=score)
Expand Down
2 changes: 2 additions & 0 deletions bazarr/api/providers/providers_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def post(self):
except OSError:
return 'Unable to save subtitles file', 500
else:
if isinstance(result, tuple) and len(result):
result = result[0]
if isinstance(result, ProcessSubtitlesResult):
history_log(2, sonarrSeriesId, sonarrEpisodeId, result)
if not settings.general.getboolean('dont_notify_manual_actions'):
Expand Down
2 changes: 2 additions & 0 deletions bazarr/api/providers/providers_movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def post(self):
except OSError:
return 'Unable to save subtitles file', 500
else:
if isinstance(result, tuple) and len(result):
result = result[0]
if isinstance(result, ProcessSubtitlesResult):
history_log_movie(2, radarrId, result)
if not settings.general.getboolean('dont_notify_manual_actions'):
Expand Down
3 changes: 2 additions & 1 deletion bazarr/api/swaggerui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"code3": fields.String(),
"path": fields.String(),
"forced": fields.Boolean(),
"hi": fields.Boolean()
"hi": fields.Boolean(),
"file_size": fields.Integer()
}

subtitles_language_model = {
Expand Down
4 changes: 3 additions & 1 deletion bazarr/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ def postprocess(item):
item['subtitles'] = ast.literal_eval(item['subtitles'])
for i, subs in enumerate(item['subtitles']):
language = subs[0].split(':')
file_size = subs[2] if len(subs) > 2 else 0
item['subtitles'][i] = {"path": path_replace(subs[1]),
"name": language_from_alpha2(language[0]),
"code2": language[0],
"code3": alpha3_from_alpha2(language[0]),
"forced": False,
"hi": False}
"hi": False,
"file_size": file_size}
if len(language) > 1:
item['subtitles'][i].update(
{
Expand Down
4 changes: 4 additions & 0 deletions bazarr/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ def base_url_slash_cleaner(uri):
'timeout': '600',
'unknown_as_english': 'False',
},
'hdbits': {
'username': '',
'passkey': '',
},
'karagarga': {
'username': '',
'password': '',
Expand Down
6 changes: 3 additions & 3 deletions bazarr/app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dogpile.cache import make_region
from datetime import datetime

from sqlalchemy import create_engine, inspect, DateTime, ForeignKey, Integer, LargeBinary, Text, func, text
from sqlalchemy import create_engine, inspect, DateTime, ForeignKey, Integer, LargeBinary, Text, func, text, BigInteger
# importing here to be indirectly imported in other modules later
from sqlalchemy import update, delete, select, func # noqa W0611
from sqlalchemy.orm import scoped_session, sessionmaker, mapped_column
Expand Down Expand Up @@ -128,7 +128,7 @@ class TableEpisodes(Base):
episode_file_id = mapped_column(Integer)
failedAttempts = mapped_column(Text)
ffprobe_cache = mapped_column(LargeBinary)
file_size = mapped_column(Integer)
file_size = mapped_column(BigInteger)
format = mapped_column(Text)
missing_subtitles = mapped_column(Text)
monitored = mapped_column(Text)
Expand Down Expand Up @@ -201,7 +201,7 @@ class TableMovies(Base):
failedAttempts = mapped_column(Text)
fanart = mapped_column(Text)
ffprobe_cache = mapped_column(LargeBinary)
file_size = mapped_column(Integer)
file_size = mapped_column(BigInteger)
format = mapped_column(Text)
imdbId = mapped_column(Text)
missing_subtitles = mapped_column(Text)
Expand Down
15 changes: 13 additions & 2 deletions bazarr/app/get_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from utilities.analytics import event_tracker


_TRACEBACK_RE = re.compile(r'File "(.*?providers/.*?)", line (\d+)')
_TRACEBACK_RE = re.compile(r'File "(.*?providers[\\/].*?)", line (\d+)')


def time_until_midnight(timezone):
Expand Down Expand Up @@ -80,6 +80,7 @@ def provider_throttle_map():
DownloadLimitExceeded: (datetime.timedelta(hours=6), "6 hours"),
DownloadLimitReached: (datetime.timedelta(hours=6), "6 hours"),
APIThrottled: (datetime.timedelta(seconds=15), "15 seconds"),
ServiceUnavailable: (datetime.timedelta(hours=1), "1 hour"),
},
"opensubtitlescom": {
AuthenticationError: (datetime.timedelta(hours=12), "12 hours"),
Expand Down Expand Up @@ -108,7 +109,13 @@ def provider_throttle_map():
SearchLimitReached: (
legendasdivx_limit_reset_timedelta(),
f"{legendasdivx_limit_reset_timedelta().seconds // 3600 + 1} hours"),
}
},
"subf2m": {
ConfigurationError: (datetime.timedelta(hours=24), "24 hours"),
},
"whisperai": {
ConnectionError: (datetime.timedelta(hours=24), "24 hours"),
},
}


Expand Down Expand Up @@ -294,6 +301,10 @@ def get_providers_auth():
'f_username': settings.karagarga.f_username,
'f_password': settings.karagarga.f_password,
},
'hdbits': {
'username': settings.hdbits.username,
'passkey': settings.hdbits.passkey,
},
'subf2m': {
'verify_ssl': settings.subf2m.getboolean('verify_ssl'),
'user_agent': settings.subf2m.user_agent,
Expand Down
17 changes: 14 additions & 3 deletions bazarr/app/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,22 @@ def movies_images(url):
@check_login
@ui_bp.route('/system/backup/download/<path:filename>', methods=['GET'])
def backup_download(filename):
return send_file(os.path.join(settings.backup.folder, filename), max_age=0, as_attachment=True)
fullpath = os.path.normpath(os.path.join(settings.backup.folder, filename))
if not fullpath.startswith(settings.backup.folder):
return '', 404
else:
return send_file(fullpath, max_age=0, as_attachment=True)


@ui_bp.route('/api/swaggerui/static/<path:filename>', methods=['GET'])
def swaggerui_static(filename):
return send_file(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'libs', 'flask_restx',
'static', filename))
basepath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'libs', 'flask_restx',
'static')
fullpath = os.path.join(basepath, filename)
if not fullpath.startswith(basepath):
return '', 404
else:
return send_file(fullpath)


def configured():
Expand All @@ -160,6 +169,8 @@ def configured():
@ui_bp.route('/test', methods=['GET'])
@ui_bp.route('/test/<protocol>/<path:url>', methods=['GET'])
def proxy(protocol, url):
if protocol.lower() not in ['http', 'https']:
return dict(status=False, error='Unsupported protocol')
url = protocol + '://' + unquote(url)
params = request.args
try:
Expand Down
Loading

0 comments on commit a09cc34

Please sign in to comment.