Beispiel #1
0
    def put(self, tvdb_id):
        """Save the settings for a show."""
        input_json = cherrypy.request.json

        if all(k in input_json for k in ('wanted_languages', 'refine',
                                         'hearing_impaired', 'utf8_encoding')):
            wanted_languages = input_json['wanted_languages']
            refine = get_boolean(input_json['refine'])
            hearing_impaired = get_boolean(input_json['hearing_impaired'])
            utf8_encoding = get_boolean(input_json['utf8_encoding'])

            # Update settings
            db = ShowSettingsDb()
            show_settings = db.get_show_settings(tvdb_id)
            show_settings.wanted_languages = wanted_languages
            show_settings.refine = refine
            show_settings.hearing_impaired = hearing_impaired
            show_settings.utf8_encoding = utf8_encoding
            db.update_show_settings(show_settings)

            # Delete wanted items for the show so the new settings will be used in the next disk scan
            WantedItemsDb().delete_wanted_items_for_show(tvdb_id)

            # Send notification
            send_websocket_notification(
                'Settings will be applied on next disk scan.')

            return self._no_content()

        return self._bad_request('Missing data')
Beispiel #2
0
    def get(self):
        shows = ShowDetailsDb().get_all_shows()
        total_shows = len(shows)

        failed_shows = FailedShowsDb().get_failed_shows()

        total_episodes = 0
        total_subtitles_wanted = 0
        total_subtitles_available = 0
        total_subtitles_missing = 0
        show_settings_db = ShowSettingsDb()
        show_details_db = ShowEpisodeDetailsDb()
        for show in shows:
            show_settings = show_settings_db.get_show_settings(show.tvdb_id)
            show_episodes = show_details_db.get_show_episodes(
                show.tvdb_id, available_only=True, subtitles=False)
            wanted_languages = show_settings.wanted_languages
            for show_episode in show_episodes:
                total_episodes += 1
                total_subtitles_wanted += len(wanted_languages)
                total_subtitles_missing += len(show_episode.missing_languages)
                total_subtitles_available += len(wanted_languages) - len(
                    show_episode.missing_languages)

        return {
            'total_shows': total_shows,
            'total_episodes': total_episodes,
            'total_subtitles_wanted': total_subtitles_wanted,
            'total_subtitles_missing': total_subtitles_missing,
            'total_subtitles_available': total_subtitles_available,
            'failed_shows': failed_shows
        }
 def __init__(self):
     self.show_db = ShowDetailsDb()
     self.failed_shows_db = FailedShowsDb()
     self.show_episodes_db = ShowEpisodeDetailsDb()
     self.show_settings_db = ShowSettingsDb()
     self.failed_movies_db = FailedMoviesDb()
     self.movie_db = MovieDetailsDb()
     self.movie_settings_db = MovieSettingsDb()
     self.show_indexer = ShowIndexer()
     self.movie_indexer = MovieIndexer()
Beispiel #4
0
    def get(self, tvdb_id):
        """Get the settings for a show"""
        show_settings_db = ShowSettingsDb()
        show_settings = show_settings_db.get_show_settings(tvdb_id)

        # If no settings are defined yet, use the default settings
        if not show_settings:
            show_settings = ShowSettings.default_settings(tvdb_id)
            show_settings_db.set_show_settings(show_settings)

        return show_settings.to_json()
Beispiel #5
0
    def get(self, tvdb_id=None):
        """Get the list of shows or the details of a single show."""
        if tvdb_id:
            db_show = ShowDetailsDb().get_show(tvdb_id)
            db_show_settings = ShowSettingsDb().get_show_settings(tvdb_id)

            # Return NotFound if movie does not longer exists on disk
            if not os.path.exists(db_show.path):
                raise NotFound()

            # Return show details
            return self._to_show_json(db_show, db_show_settings, details=True)

        else:
            shows = []
            show_settings_db = ShowSettingsDb()
            db_shows = ShowDetailsDb().get_all_shows()
            for db_show in db_shows:
                db_show_settings = show_settings_db.get_show_settings(
                    db_show.tvdb_id)
                shows.append(self._to_show_json(db_show, db_show_settings))

            return shows
Beispiel #6
0
 def __init__(self):
     super(DiskScanner, self).__init__()
     self.wanted_db = WantedItemsDb()
     self.show_settings_db = ShowSettingsDb()
     self.movie_settings_db = MovieSettingsDb()
Beispiel #7
0
    def delete(self, tvdb_id):
        # Delete from database
        ShowDetailsDb().delete_show(tvdb_id, episodes=True, subtitles=True)
        ShowSettingsDb().delete_show_settings(tvdb_id)

        return self._no_content()