Merge pull request #3 from morpheus65535/development

Development
pull/2825/head
destpstrzy 3 months ago committed by GitHub
commit 601f3fafe5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,7 +12,9 @@ from operator import itemgetter
from app.get_providers import get_enabled_providers
from app.database import TableAnnouncements, database, insert, select
from .get_args import args
from app.config import settings
from app.get_args import args
from sonarr.info import get_sonarr_info
from radarr.info import get_radarr_info
from app.check_update import deprecated_python_version
@ -79,10 +81,10 @@ def get_local_announcements():
# opensubtitles.org end-of-life
enabled_providers = get_enabled_providers()
if enabled_providers and 'opensubtitles' in enabled_providers:
if enabled_providers and 'opensubtitles' in enabled_providers and not settings.opensubtitles.vip:
announcements.append({
'text': 'Opensubtitles.org will be deprecated soon, migrate to Opensubtitles.com ASAP and disable this '
'provider to remove this announcement.',
'text': 'Opensubtitles.org is deprecated for non-VIP users, migrate to Opensubtitles.com ASAP and disable '
'this provider to remove this announcement.',
'link': 'https://wiki.bazarr.media/Troubleshooting/OpenSubtitles-migration/',
'dismissible': False,
'timestamp': 1676236978,

@ -333,10 +333,6 @@ def update_one_movie(movie_id, action, defer_search=False):
logging.debug(
f'BAZARR inserted this movie into the database:{path_mappings.path_replace_movie(movie["path"])}')
# Storing existing subtitles
logging.debug(f'BAZARR storing subtitles for this movie: {path_mappings.path_replace_movie(movie["path"])}')
store_subtitles_movie(movie['path'], path_mappings.path_replace_movie(movie['path']))
# Downloading missing subtitles
if defer_search:
logging.debug(

@ -258,10 +258,6 @@ def sync_one_episode(episode_id, defer_search=False):
logging.debug(
f'BAZARR inserted this episode into the database:{path_mappings.path_replace(episode["path"])}')
# Storing existing subtitles
logging.debug(f'BAZARR storing subtitles for this episode: {path_mappings.path_replace(episode["path"])}')
store_subtitles(episode['path'], path_mappings.path_replace(episode['path']))
# Downloading missing subtitles
if defer_search:
logging.debug(
@ -270,4 +266,4 @@ def sync_one_episode(episode_id, defer_search=False):
else:
logging.debug(
f'BAZARR downloading missing subtitles for this episode: {path_mappings.path_replace(episode["path"])}')
episode_download_subtitles(episode_id)
episode_download_subtitles(episode_id, send_progress=True)

@ -132,7 +132,7 @@ def store_subtitles(original_path, reversed_path, use_cache=True):
.values(subtitles=str(actual_subtitles))
.where(TableEpisodes.path == original_path))
matching_episodes = database.execute(
select(TableEpisodes.sonarrEpisodeId, TableEpisodes.sonarrSeriesId)
select(TableEpisodes.sonarrEpisodeId)
.where(TableEpisodes.path == original_path))\
.all()

@ -24,6 +24,8 @@ language_converters.register('assrt = subliminal_patch.converters.assrt:AssrtCon
server_url = 'https://api.assrt.net/v1'
supported_languages = list(language_converters['assrt'].to_assrt.keys())
meaningless_videoname = ['不知道']
def get_request_delay(max_request_per_minute):
return ceil(60 / max_request_per_minute)
@ -203,8 +205,21 @@ class AssrtProvider(Provider):
language = Language.fromassrt(match.group('code'))
output_language = search_language_in_list(language, languages)
if output_language:
subtitles.append(AssrtSubtitle(output_language, sub['id'], sub['videoname'], self.session,
self.token, self.max_request_per_minute))
if sub['videoname'] not in meaningless_videoname:
video_name = sub['videoname']
elif 'native_name' in sub and isinstance(sub['native_name'], str):
video_name = sub['native_name']
elif ('native_name' in sub and isinstance(sub['native_name'], list) and
len(sub['native_name']) > 0):
video_name = sub['native_name'][0]
else:
video_name = None
subtitles.append(AssrtSubtitle(language=output_language,
subtitle_id=sub['id'],
video_name=video_name,
session=self.session,
token=self.token,
max_request_per_minute=self.max_request_per_minute))
except:
pass

@ -17,6 +17,8 @@ from requests.adapters import HTTPAdapter
from subliminal.utils import sanitize
from subliminal_patch.subtitle import guess_matches
from subliminal_patch.providers.mixins import ProviderSubtitleArchiveMixin
from subliminal_patch.exceptions import TooManyRequests
try:
from lxml import etree
@ -205,6 +207,8 @@ class PodnapisiProvider(_PodnapisiProvider, ProviderSubtitleArchiveMixin):
content = self.session.get(self.server_url + 'search/old', params=params, timeout=30).content
xml = etree.fromstring(content)
except etree.ParseError:
if '429 Too Many Requests' in content:
raise TooManyRequests
logger.error("Wrong data returned: %r", content)
break

@ -9,23 +9,51 @@ import {
Text,
} from "@mantine/core";
import { ColumnDef } from "@tanstack/react-table";
import {
useEpisodeSubtitleModification,
useMovieSubtitleModification,
} from "@/apis/hooks";
import Language from "@/components/bazarr/Language";
import SubtitleToolsMenu from "@/components/SubtitleToolsMenu";
import SimpleTable from "@/components/tables/SimpleTable";
import { withModal } from "@/modules/modals";
import { isMovie } from "@/utilities";
import { useModals, withModal } from "@/modules/modals";
import { task, TaskGroup } from "@/modules/task";
import { fromPython, isMovie, toPython } from "@/utilities";
type SupportType = Item.Episode | Item.Movie;
type TableColumnType = FormType.ModifySubtitle & {
raw_language: Language.Info;
seriesId: number;
name: string;
isMovie: boolean;
};
type LocalisedType = {
id: number;
seriesId: number;
type: "movie" | "episode";
name: string;
isMovie: boolean;
};
function getIdAndType(item: SupportType): [number, "episode" | "movie"] {
function getLocalisedValues(item: SupportType): LocalisedType {
if (isMovie(item)) {
return [item.radarrId, "movie"];
return {
seriesId: 0,
id: item.radarrId,
type: "movie",
name: item.title,
isMovie: true,
};
} else {
return [item.sonarrEpisodeId, "episode"];
return {
seriesId: item.sonarrSeriesId,
id: item.sonarrEpisodeId,
type: "episode",
name: item.title,
isMovie: false,
};
}
}
@ -41,6 +69,11 @@ const SubtitleToolView: FunctionComponent<SubtitleToolViewProps> = ({
payload,
}) => {
const [selections, setSelections] = useState<TableColumnType[]>([]);
const { remove: removeEpisode, download: downloadEpisode } =
useEpisodeSubtitleModification();
const { download: downloadMovie, remove: removeMovie } =
useMovieSubtitleModification();
const modals = useModals();
const columns = useMemo<ColumnDef<TableColumnType>[]>(
() => [
@ -109,17 +142,22 @@ const SubtitleToolView: FunctionComponent<SubtitleToolViewProps> = ({
const data = useMemo<TableColumnType[]>(
() =>
payload.flatMap((item) => {
const [id, type] = getIdAndType(item);
const { seriesId, id, type, name, isMovie } = getLocalisedValues(item);
return item.subtitles.flatMap((v) => {
if (v.path) {
return [
{
id,
seriesId,
type,
language: v.code2,
path: v.path,
// eslint-disable-next-line camelcase
raw_language: v,
name,
hi: toPython(v.forced),
forced: toPython(v.hi),
isMovie,
},
];
} else {
@ -143,7 +181,51 @@ const SubtitleToolView: FunctionComponent<SubtitleToolViewProps> = ({
></SimpleTable>
<Divider></Divider>
<Group>
<SubtitleToolsMenu selections={selections}>
<SubtitleToolsMenu
selections={selections}
onAction={(action) => {
selections.forEach((selection) => {
const actionPayload = {
form: {
language: selection.language,
hi: fromPython(selection.hi),
forced: fromPython(selection.forced),
path: selection.path,
},
radarrId: 0,
seriesId: 0,
episodeId: 0,
};
if (selection.isMovie) {
actionPayload.radarrId = selection.id;
} else {
actionPayload.seriesId = selection.seriesId;
actionPayload.episodeId = selection.id;
}
const download = selection.isMovie
? downloadMovie
: downloadEpisode;
const remove = selection.isMovie ? removeMovie : removeEpisode;
if (action === "search") {
task.create(
selection.name,
TaskGroup.SearchSubtitle,
download.mutateAsync,
actionPayload,
);
} else if (action === "delete" && selection.path) {
task.create(
selection.name,
TaskGroup.DeleteSubtitle,
remove.mutateAsync,
actionPayload,
);
}
});
modals.closeAll();
}}
>
<Button disabled={selections.length === 0} variant="light">
Select Action
</Button>

Loading…
Cancel
Save