Example #1
0
    def addDefaultShow(indexer, indexer_id, name, status):
        """
        Adds a new show with the default settings
        """
        if not findCertainShow(int(indexer_id)):
            sickrage.app.log.info("Adding show " + str(indexer_id))
            root_dirs = sickrage.app.config.root_dirs.split('|')

            try:
                location = root_dirs[int(root_dirs[0]) + 1]
            except Exception:
                location = None

            if location:
                showPath = os.path.join(location, sanitizeFileName(name))
                dir_exists = makeDir(showPath)

                if not dir_exists:
                    sickrage.app.log.warning("Unable to create the folder %s , can't add the show" % showPath)
                    return
                else:
                    chmod_as_parent(showPath)

                sickrage.app.show_queue.addShow(int(indexer), int(indexer_id), showPath,
                                                default_status=status,
                                                quality=int(sickrage.app.config.quality_default),
                                                flatten_folders=int(sickrage.app.config.flatten_folders_default),
                                                paused=sickrage.app.config.trakt_start_paused,
                                                default_status_after=status,
                                                skip_downloaded=sickrage.app.config.skip_downloaded_default)
            else:
                sickrage.app.log.warning(
                    "There was an error creating the show, no root directory setting found")
                return
Example #2
0
    def _write_image(self, image_data, image_path, force=False):
        """
        Saves the data in image_data to the location image_path. Returns True/False
        to represent success or failure.

        image_data: binary image data to write to file
        image_path: file location to save the image to
        """

        # don't bother overwriting it
        if os.path.isfile(image_path) and not force:
            sickrage.app.log.debug("Image already exists, not downloading")
            return False

        image_dir = os.path.dirname(image_path)

        if not image_data:
            sickrage.app.log.debug("Unable to retrieve image to save in %s, skipping" % image_path)
            return False

        try:
            if not os.path.isdir(image_dir):
                sickrage.app.log.debug("Metadata dir didn't exist, creating it at " + image_dir)
                os.makedirs(image_dir)
                chmod_as_parent(image_dir)

            with open(image_path, 'wb') as outFile:
                outFile.write(image_data)

            chmod_as_parent(image_path)
        except IOError as e:
            sickrage.app.log.warning("Unable to write image to " + image_path + " - are you sure the show folder is writable? {}".format(e))
            return False

        return True
Example #3
0
    def get_subtitles_path(self, video_path):
        if Path(sickrage.app.config.subtitles_dir).is_absolute() and Path(sickrage.app.config.subtitles_dir).exists():
            new_subtitles_path = sickrage.app.config.subtitles_dir
        elif sickrage.app.config.subtitles_dir:
            new_subtitles_path = Path(os.path.dirname(video_path)).joinpath(sickrage.app.config.subtitles_dir.strip('/'))
            dir_exists = make_dir(new_subtitles_path)
            if not dir_exists:
                sickrage.app.log.warning('Unable to create subtitles folder {}'.format(new_subtitles_path))
            else:
                chmod_as_parent(new_subtitles_path)
        else:
            new_subtitles_path = Path(video_path).parent

        return new_subtitles_path
Example #4
0
def get_subtitles_path(video_path):
    if os.path.isabs(sickrage.app.config.subtitles_dir):
        new_subtitles_path = sickrage.app.config.subtitles_dir
    elif sickrage.app.config.subtitles_dir:
        new_subtitles_path = os.path.join(os.path.dirname(video_path), sickrage.app.config.subtitles_dir)
        dir_exists = makeDir(new_subtitles_path)
        if not dir_exists:
            sickrage.app.log.warning('Unable to create subtitles folder {}'.format(new_subtitles_path))
        else:
            chmod_as_parent(new_subtitles_path)
    else:
        new_subtitles_path = os.path.dirname(video_path)

    return new_subtitles_path
Example #5
0
    def dumpHTML(data):
        dumpName = os.path.join(sickrage.app.cache_dir, 'custom_torrent.html')

        try:
            with open(dumpName, 'wb') as fileOut:
                fileOut.write(data)

            chmod_as_parent(dumpName)

            sickrage.app.log.info("Saved custom_torrent html dump %s " % dumpName)
        except IOError as e:
            sickrage.app.log.error("Unable to save the file: %s " % repr(e))
            return False

        return True
Example #6
0
    def write_ep_file(self, ep_obj):
        """
        Generates and writes ep_obj's metadata under the given path with the
        given filename root. Uses the episode's name with the extension in
        _ep_nfo_extension.

        ep_obj: TVEpisode object for which to create the metadata

        file_name_path: The file name to use for this metadata. Note that the extension
                will be automatically added based on _ep_nfo_extension. This should
                include an absolute path.

        Note that this method expects that _ep_data will return an ElementTree
        object. If your _ep_data returns data in another format yo'll need to
        override this method.
        """

        data = self._ep_data(ep_obj)

        if not data:
            return False

        nfo_file_path = self.get_episode_file_path(ep_obj)
        nfo_file_dir = os.path.dirname(nfo_file_path)

        try:
            if not os.path.isdir(nfo_file_dir):
                sickrage.app.log.debug(
                    "Metadata dir didn't exist, creating it at " +
                    nfo_file_dir)
                os.makedirs(nfo_file_dir)
                chmod_as_parent(nfo_file_dir)

            sickrage.app.log.debug("Writing episode nfo file to " +
                                   nfo_file_path)

            nfo_file = open(nfo_file_path, 'wb')

            data.write(nfo_file)
            nfo_file.close()
            chmod_as_parent(nfo_file_path)
        except IOError as e:
            sickrage.app.log.warning(
                "Unable to write file to " + nfo_file_path +
                " - are you sure the folder is writable? {}".format(e))
            return False

        return True
Example #7
0
def get_subtitles_path(video_path):
    if os.path.isabs(sickrage.app.config.subtitles_dir):
        new_subtitles_path = sickrage.app.config.subtitles_dir
    elif sickrage.app.config.subtitles_dir:
        new_subtitles_path = os.path.join(os.path.dirname(video_path),
                                          sickrage.app.config.subtitles_dir)
        dir_exists = makeDir(new_subtitles_path)
        if not dir_exists:
            sickrage.app.log.warning(
                'Unable to create subtitles folder {}'.format(
                    new_subtitles_path))
        else:
            chmod_as_parent(new_subtitles_path)
    else:
        new_subtitles_path = os.path.dirname(video_path)

    return new_subtitles_path
Example #8
0
    def write_show_file(self, show_obj):
        """
        Generates and writes show_obj's metadata under the given path to the
        filename given by get_show_file_path()

        show_obj: TVShow object for which to create the metadata

        path: An absolute or relative path where we should put the file. Note that
                the file name will be the default show_file_name.

        Note that this method expects that _show_data will return an ElementTree
        object. If your _show_data returns data in another format yo'll need to
        override this method.
        """

        data = self._show_data(show_obj)

        if not data:
            return False

        nfo_file_path = self.get_show_file_path(show_obj)
        nfo_file_dir = os.path.dirname(nfo_file_path)

        try:
            if not os.path.isdir(nfo_file_dir):
                sickrage.app.log.debug(
                    "Metadata dir didn't exist, creating it at " +
                    nfo_file_dir)
                os.makedirs(nfo_file_dir)
                chmod_as_parent(nfo_file_dir)

            sickrage.app.log.debug("Writing show nfo file to " + nfo_file_path)

            nfo_file = io.open(nfo_file_path, 'wb')

            data.write(nfo_file)
            nfo_file.close()
            chmod_as_parent(nfo_file_path)
        except IOError as e:
            sickrage.app.log.error(
                "Unable to write file to " + nfo_file_path +
                " - are you sure the folder is writable? {}".format(e))
            return False

        return True
Example #9
0
    def download(self, url, filename, **kwargs):
        try:
            r = self.get(url, timeout=10, stream=True, **kwargs)
            if r.status_code >= 400:
                return False

            with io.open(filename, 'wb') as f:
                for chunk in r.iter_content(chunk_size=1024):
                    if chunk:
                        f.write(chunk)

            chmod_as_parent(filename)
        except Exception as e:
            sickrage.app.log.debug("Failed to download file from {} - ERROR: {}".format(url, e))
            remove_file_failed(filename)
            return False

        return True
Example #10
0
    def write_ep_file(self, ep_obj):
        """
        Generates and writes ep_obj's metadata under the given path with the
        given filename root. Uses the episode's name with the extension in
        _ep_nfo_extension.

        ep_obj: TVEpisode object for which to create the metadata

        file_name_path: The file name to use for this metadata. Note that the extension
                will be automatically added based on _ep_nfo_extension. This should
                include an absolute path.
        """
        data = self._ep_data(ep_obj)

        if not data:
            return False

        nfo_file_path = self.get_episode_file_path(ep_obj)
        nfo_file_dir = os.path.dirname(nfo_file_path)

        try:
            if not os.path.isdir(nfo_file_dir):
                sickrage.app.log.debug(
                    "Metadata dir didn't exist, creating it at " +
                    nfo_file_dir)
                os.makedirs(nfo_file_dir)
                chmod_as_parent(nfo_file_dir)

            sickrage.app.log.debug("Writing episode nfo file to " +
                                   nfo_file_path)

            with open(nfo_file_path, 'w') as nfo_file:
                # Calling encode directly, b/c often descriptions have wonky characters.
                nfo_file.write(data)

            chmod_as_parent(nfo_file_path)

        except EnvironmentError as e:
            sickrage.app.log.warning(
                "Unable to write file to " + nfo_file_path +
                " - are you sure the folder is writable? {}".format(e))
            return False

        return True
Example #11
0
    def write_ep_file(self, ep_obj):
        """
        Generates and writes ep_obj's metadata under the given path with the
        given filename root. Uses the episode's name with the extension in
        _ep_nfo_extension.

        ep_obj: TVEpisode object for which to create the metadata

        file_name_path: The file name to use for this metadata. Note that the extension
                will be automatically added based on _ep_nfo_extension. This should
                include an absolute path.

        Note that this method expects that _ep_data will return an ElementTree
        object. If your _ep_data returns data in another format yo'll need to
        override this method.
        """

        data = self._ep_data(ep_obj)

        if not data:
            return False

        nfo_file_path = self.get_episode_file_path(ep_obj)
        nfo_file_dir = os.path.dirname(nfo_file_path)

        try:
            if not os.path.isdir(nfo_file_dir):
                sickrage.app.log.debug("Metadata dir didn't exist, creating it at " + nfo_file_dir)
                os.makedirs(nfo_file_dir)
                chmod_as_parent(nfo_file_dir)

            sickrage.app.log.debug("Writing episode nfo file to " + nfo_file_path)

            nfo_file = io.open(nfo_file_path, 'wb')

            data.write(nfo_file)
            nfo_file.close()
            chmod_as_parent(nfo_file_path)
        except IOError as e:
            sickrage.app.log.warning(
                "Unable to write file to " + nfo_file_path + " - are you sure the folder is writable? {}".format(e))
            return False

        return True
Example #12
0
    def add_default_show(indexer, indexer_id, name, status):
        """
        Adds a new show with the default settings
        """
        if not find_show(int(indexer_id)):
            sickrage.app.log.info("Adding show " + str(indexer_id))
            root_dirs = sickrage.app.config.root_dirs.split('|')

            try:
                location = root_dirs[int(root_dirs[0]) + 1]
            except Exception:
                location = None

            if location:
                showPath = os.path.join(location, sanitize_file_name(name))
                dir_exists = make_dir(showPath)

                if not dir_exists:
                    sickrage.app.log.warning(
                        "Unable to create the folder %s , can't add the show" %
                        showPath)
                    return
                else:
                    chmod_as_parent(showPath)

                sickrage.app.show_queue.add_show(
                    int(indexer),
                    int(indexer_id),
                    showPath,
                    default_status=status,
                    quality=int(sickrage.app.config.quality_default),
                    flatten_folders=int(
                        sickrage.app.config.flatten_folders_default),
                    paused=sickrage.app.config.trakt_start_paused,
                    default_status_after=status,
                    scene=sickrage.app.config.scene_default,
                    skip_downloaded=sickrage.app.config.skip_downloaded_default
                )
            else:
                sickrage.app.log.warning(
                    "There was an error creating the show, no root directory setting found"
                )
                return
Example #13
0
    def write_show_file(self, show_obj):
        """
        Generates and writes show_obj's metadata under the given path to the
        filename given by get_show_file_path()

        show_obj: TVShow object for which to create the metadata

        path: An absolute or relative path where we should put the file. Note that
                the file name will be the default show_file_name.

        Note that this method expects that _show_data will return an ElementTree
        object. If your _show_data returns data in another format yo'll need to
        override this method.
        """

        data = self._show_data(show_obj)

        if not data:
            return False

        nfo_file_path = self.get_show_file_path(show_obj)
        nfo_file_dir = os.path.dirname(nfo_file_path)

        try:
            if not os.path.isdir(nfo_file_dir):
                sickrage.app.log.debug("Metadata dir didn't exist, creating it at " + nfo_file_dir)
                os.makedirs(nfo_file_dir)
                chmod_as_parent(nfo_file_dir)

            sickrage.app.log.debug("Writing show nfo file to " + nfo_file_path)

            nfo_file = io.open(nfo_file_path, 'wb')

            data.write(nfo_file)
            nfo_file.close()
            chmod_as_parent(nfo_file_path)
        except IOError as e:
            sickrage.app.log.error(
                "Unable to write file to " + nfo_file_path + " - are you sure the folder is writable? {}".format(e))
            return False

        return True
Example #14
0
    def download_result(self, result):
        """
        Downloads a result to the appropriate black hole folder.

        :param result: SearchResult instance to download.
        :return: boolean, True on success
        """

        if not result.content:
            return False

        filename = self.make_filename(result.name)

        # Support for Jackett/TorzNab
        if (result.url.endswith('torrent') or result.url.startswith('magnet')) and self.type in ['nzb', 'newznab']:
            filename = "{}.torrent".format(filename.rsplit('.', 1)[0])

        if result.type == "nzb":
            sickrage.app.log.info("Saving NZB to " + filename)

            # write content to torrent file
            with open(filename, 'wb') as f:
                f.write(result.content)

            return True
        elif result.type == "nzbdata":
            filename = os.path.join(sickrage.app.config.nzb_dir, result.name + ".nzb")

            sickrage.app.log.info("Saving NZB to " + filename)

            # save the data to disk
            try:
                with open(filename, 'w') as fileOut:
                    fileOut.write(result.extraInfo[0])

                chmod_as_parent(filename)

                return True
            except EnvironmentError as e:
                sickrage.app.log.error("Error trying to save NZB to black hole: {}".format(e))
Example #15
0
    def write_ep_file(self, ep_obj):
        """
        Generates and writes ep_obj's metadata under the given path with the
        given filename root. Uses the episode's name with the extension in
        _ep_nfo_extension.

        ep_obj: TVEpisode object for which to create the metadata

        file_name_path: The file name to use for this metadata. Note that the extension
                will be automatically added based on _ep_nfo_extension. This should
                include an absolute path.
        """
        data = self._ep_data(ep_obj)

        if not data:
            return False

        nfo_file_path = self.get_episode_file_path(ep_obj)
        nfo_file_dir = os.path.dirname(nfo_file_path)

        try:
            if not os.path.isdir(nfo_file_dir):
                sickrage.app.log.debug("Metadata dir didn't exist, creating it at " + nfo_file_dir)
                os.makedirs(nfo_file_dir)
                chmod_as_parent(nfo_file_dir)

            sickrage.app.log.debug("Writing episode nfo file to " + nfo_file_path)

            with io.open(nfo_file_path, 'w') as nfo_file:
                # Calling encode directly, b/c often descriptions have wonky characters.
                nfo_file.write(data.encode("utf-8"))

            chmod_as_parent(nfo_file_path)

        except EnvironmentError as e:
            sickrage.app.log.warning(
                "Unable to write file to " + nfo_file_path + " - are you sure the folder is writable? {}".format(e))
            return False

        return True
Example #16
0
    def _write_image(self, image_data, image_path, force=False):
        """
        Saves the data in image_data to the location image_path. Returns True/False
        to represent success or failure.

        image_data: binary image data to write to file
        image_path: file location to save the image to
        """

        # don't bother overwriting it
        if os.path.isfile(image_path) and not force:
            sickrage.app.log.debug("Image already exists, not downloading")
            return False

        image_dir = os.path.dirname(image_path)

        if not image_data:
            sickrage.app.log.debug("Unable to retrieve image to save in %s, skipping" % image_path)
            return False

        try:
            if not os.path.isdir(image_dir):
                sickrage.app.log.debug("Metadata dir didn't exist, creating it at " + image_dir)
                os.makedirs(image_dir)
                chmod_as_parent(image_dir)

            with io.open(image_path, 'wb') as outFile:
                outFile.write(image_data)

            chmod_as_parent(image_path)
        except IOError as e:
            sickrage.app.log.warning(
                "Unable to write image to " + image_path + " - are you sure the show folder is writable? {}".format(e))
            return False

        return True
Example #17
0
    async def post(self, *args, **kwargs):
        """
        Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are
        provided then it forwards back to newShow, if not it goes to /home.
        """

        whichSeries = self.get_argument('whichSeries', None)
        rootDir = self.get_argument('rootDir', None)
        fullShowPath = self.get_argument('fullShowPath', None)
        providedName = self.get_argument('providedName', None)
        indexerLang = self.get_argument('indexerLang', None)
        defaultStatus = self.get_argument('defaultStatus', None)
        quality_preset = self.get_argument('quality_preset', None)
        anyQualities = self.get_arguments('anyQualities')
        bestQualities = self.get_arguments('bestQualities')
        flatten_folders = self.get_argument('flatten_folders', None)
        subtitles = self.get_argument('subtitles', None)
        sub_use_sr_metadata = self.get_argument('sub_use_sr_metadata', None)
        other_shows = self.get_arguments('other_shows')
        skipShow = self.get_argument('skipShow', None)
        providedIndexer = self.get_argument('providedIndexer', None)
        anime = self.get_argument('anime', None)
        scene = self.get_argument('scene', None)
        blacklist = self.get_argument('blacklist', None)
        whitelist = self.get_argument('whitelist', None)
        defaultStatusAfter = self.get_argument('defaultStatusAfter', None)
        skip_downloaded = self.get_argument('skip_downloaded', None)
        add_show_year = self.get_argument('add_show_year', None)

        indexerLang = indexerLang or sickrage.app.config.indexer_default_language

        # if we're skipping then behave accordingly
        if skipShow:
            return self.write(await self.finish_add_show(other_shows))

        if not whichSeries:
            return self.redirect("/home/")

        # figure out what show we're adding and where
        series_pieces = whichSeries.split('|')
        if (whichSeries and rootDir
                or whichSeries and fullShowPath) and len(series_pieces) > 1:
            if len(series_pieces) < 6:
                sickrage.app.log.error(
                    'Unable to add show due to show selection. Not anough arguments: %s'
                    % (repr(series_pieces)))
                sickrage.app.alerts.error(
                    _('Unknown error. Unable to add show due to problem with show selection.'
                      ))
                return self.redirect('/home/addShows/existingShows/')

            indexer = int(series_pieces[1])
            indexer_id = int(series_pieces[3])
            show_name = series_pieces[4]
        else:
            indexer = int(providedIndexer
                          or sickrage.app.config.indexer_default)
            indexer_id = int(whichSeries)
            if fullShowPath:
                show_name = os.path.basename(os.path.normpath(fullShowPath))
            else:
                show_name = providedName

        # use the whole path if it's given, or else append the show name to the root dir to get the full show path
        if fullShowPath:
            show_dir = os.path.normpath(fullShowPath)
        else:
            show_dir = os.path.join(rootDir, sanitize_file_name(show_name))
            if add_show_year and not re.match(r'.*\(\d+\)$',
                                              show_dir) and re.search(
                                                  r'\d{4}', series_pieces[5]):
                show_dir = "{} ({})".format(
                    show_dir,
                    re.search(r'\d{4}', series_pieces[5]).group(0))

        # blanket policy - if the dir exists you should have used "add existing show" numbnuts
        if os.path.isdir(show_dir) and not fullShowPath:
            sickrage.app.alerts.error(
                _("Unable to add show"),
                _("Folder ") + show_dir + _(" exists already"))
            return self.redirect('/home/addShows/existingShows/')

        # don't create show dir if config says not to
        if sickrage.app.config.add_shows_wo_dir:
            sickrage.app.log.info("Skipping initial creation of " + show_dir +
                                  " due to SiCKRAGE configuation setting")
        else:
            dir_exists = make_dir(show_dir)
            if not dir_exists:
                sickrage.app.log.warning("Unable to create the folder " +
                                         show_dir + ", can't add the show")
                sickrage.app.alerts.error(
                    _("Unable to add show"),
                    _("Unable to create the folder " + show_dir +
                      ", can't add the show"))

                # Don't redirect to default page because user wants to see the new show
                return self.redirect("/home/")
            else:
                chmod_as_parent(show_dir)

        # prepare the inputs for passing along
        scene = checkbox_to_value(scene)
        anime = checkbox_to_value(anime)
        flatten_folders = checkbox_to_value(flatten_folders)
        subtitles = checkbox_to_value(subtitles)
        sub_use_sr_metadata = checkbox_to_value(sub_use_sr_metadata)
        skip_downloaded = checkbox_to_value(skip_downloaded)

        if whitelist:
            whitelist = short_group_names(whitelist)
        if blacklist:
            blacklist = short_group_names(blacklist)

        newQuality = try_int(quality_preset, None)
        if not newQuality:
            newQuality = Quality.combine_qualities(map(int, anyQualities),
                                                   map(int, bestQualities))

        # add the show
        sickrage.app.show_queue.add_show(
            indexer=indexer,
            indexer_id=indexer_id,
            showDir=show_dir,
            default_status=int(defaultStatus),
            quality=newQuality,
            flatten_folders=flatten_folders,
            lang=indexerLang,
            subtitles=subtitles,
            sub_use_sr_metadata=sub_use_sr_metadata,
            anime=anime,
            scene=scene,
            paused=None,
            blacklist=blacklist,
            whitelist=whitelist,
            default_status_after=int(defaultStatusAfter),
            skip_downloaded=skip_downloaded)

        sickrage.app.alerts.message(
            _('Adding Show'),
            _('Adding the specified show into ') + show_dir)

        return self.write(await self.finish_add_show(other_shows))
Example #18
0
    def post(self):
        data = json_decode(self.request.body)

        is_existing = data.get('isExisting', 'false')

        root_directory = data.get('rootDirectory', None)
        series_id = data.get('seriesId', None)
        series_name = data.get('seriesName', None)
        series_directory = data.get('seriesDirectory', None)
        first_aired = data.get('firstAired', None)
        series_provider_slug = data.get('seriesProviderSlug', None)
        series_provider_language = data.get('seriesProviderLanguage', None)
        default_status = data.get('defaultStatus', None)
        default_status_after = data.get('defaultStatusAfter', None)
        quality_preset = data.get('qualityPreset', None)
        allowed_qualities = data.get('allowedQualities', [])
        preferred_qualities = data.get('preferredQualities', [])
        subtitles = self._parse_boolean(
            data.get('subtitles', sickrage.app.config.subtitles.default))
        sub_use_sr_metadata = self._parse_boolean(
            data.get('subUseSrMetadata', 'false'))
        flatten_folders = self._parse_boolean(
            data.get('flattenFolders',
                     sickrage.app.config.general.flatten_folders_default))
        is_anime = self._parse_boolean(
            data.get('isAnime', sickrage.app.config.general.anime_default))
        is_scene = self._parse_boolean(
            data.get('isScene', sickrage.app.config.general.scene_default))
        search_format = data.get(
            'searchFormat',
            sickrage.app.config.general.search_format_default.name)
        dvd_order = self._parse_boolean(data.get('dvdOrder', 'false'))
        skip_downloaded = self._parse_boolean(
            data.get('skipDownloaded',
                     sickrage.app.config.general.skip_downloaded_default))
        add_show_year = self._parse_boolean(data.get('addShowYear', 'false'))

        if not series_id:
            return self.send_error(
                400, error=f"Missing seriesId parameter: {series_id}")

        series_provider_id = SeriesProviderID.by_slug(series_provider_slug)
        if not series_provider_id:
            return self.send_error(
                404,
                error="Unable to identify a series provider using provided slug"
            )

        series = find_show(int(series_id), series_provider_id)
        if series:
            return self.send_error(400,
                                   error=f"Already exists series: {series_id}")

        if is_existing and not series_directory:
            return self.send_error(400,
                                   error="Missing seriesDirectory parameter")

        if not is_existing:
            series_directory = os.path.join(root_directory,
                                            sanitize_file_name(series_name))

            if first_aired:
                series_year = re.search(r'\d{4}', first_aired)
                if add_show_year and not re.match(
                        r'.*\(\d+\)$', series_directory) and series_year:
                    series_directory = f"{series_directory} ({series_year.group()})"

            if os.path.isdir(series_directory):
                sickrage.app.alerts.error(
                    _("Unable to add show"),
                    _("Folder ") + series_directory + _(" exists already"))
                return self.send_error(
                    400,
                    error=f"Show directory {series_directory} already exists!")

            if not make_dir(series_directory):
                sickrage.app.log.warning(
                    f"Unable to create the folder {series_directory}, can't add the show"
                )
                sickrage.app.alerts.error(
                    _("Unable to add show"),
                    _(f"Unable to create the folder {series_directory}, can't add the show"
                      ))
                return self.send_error(
                    400,
                    error=
                    f"Unable to create the show folder {series_directory}, can't add the show"
                )

        chmod_as_parent(series_directory)

        try:
            new_quality = Qualities[quality_preset.upper()]
        except KeyError:
            new_quality = Quality.combine_qualities(
                [Qualities[x.upper()] for x in allowed_qualities],
                [Qualities[x.upper()] for x in preferred_qualities])

        sickrage.app.show_queue.add_show(
            series_provider_id=series_provider_id,
            series_id=int(series_id),
            showDir=series_directory,
            default_status=EpisodeStatus[default_status.upper()],
            default_status_after=EpisodeStatus[default_status_after.upper()],
            quality=new_quality,
            flatten_folders=flatten_folders,
            lang=series_provider_language,
            subtitles=subtitles,
            sub_use_sr_metadata=sub_use_sr_metadata,
            anime=is_anime,
            dvd_order=dvd_order,
            search_format=SearchFormat[search_format.upper()],
            paused=False,
            # blacklist=blacklist,
            # whitelist=whitelist,
            scene=is_scene,
            skip_downloaded=skip_downloaded)

        sickrage.app.alerts.message(
            _('Adding Show'),
            _(f'Adding the specified show into {series_directory}'))

        return self.write_json({'message': True})