示例#1
0
    def update_mopidy_config(config_file=None, ) -> None:
        """Updates mopidy's config with the credentials stored in the database.
        If no config_file is given, the default one is used."""
        if settings.DOCKER:
            # raveberry cannot restart mopidy in the docker setup
            return

        if config_file is None:
            config_file = System._get_mopidy_config()

        spotify_username = Settings.get_setting("spotify_username", "")
        spotify_password = Settings.get_setting("spotify_password", "")
        spotify_client_id = Settings.get_setting("spotify_client_id", "")
        spotify_client_secret = Settings.get_setting("spotify_client_secret",
                                                     "")
        soundcloud_auth_token = Settings.get_setting("soundcloud_auth_token",
                                                     "")

        subprocess.call([
            "sudo",
            "/usr/local/sbin/raveberry/update_mopidy_config",
            config_file,
            spotify_username,
            spotify_password,
            spotify_client_id,
            spotify_client_secret,
            soundcloud_auth_token,
        ])
        subprocess.call(["sudo", "/usr/local/sbin/raveberry/restart_mopidy"])
        time.sleep(3)
示例#2
0
    def update_mopidy_config(output=None) -> None:
        """Updates mopidy's config with the credentials stored in the database.
        If no config_file is given, the default one is used."""
        if settings.DOCKER:
            # raveberry cannot restart mopidy in the docker setup
            return

        if not output:
            if shutil.which("cava"):
                output = "cava"
            else:
                output = "regular"

        spotify_username = Settings.get_setting("spotify_username", "")
        spotify_password = Settings.get_setting("spotify_password", "")
        spotify_client_id = Settings.get_setting("spotify_client_id", "")
        spotify_client_secret = Settings.get_setting("spotify_client_secret",
                                                     "")
        soundcloud_auth_token = Settings.get_setting("soundcloud_auth_token",
                                                     "")

        subprocess.call([
            "sudo",
            "/usr/local/sbin/raveberry/update_mopidy_config",
            output,
            spotify_username,
            spotify_password,
            spotify_client_id,
            spotify_client_secret,
            soundcloud_auth_token,
        ])
        subprocess.call(["sudo", "/usr/local/sbin/raveberry/restart_mopidy"])
        time.sleep(3)
示例#3
0
 def __init__(self) -> None:
     self.settings = Settings(self)
     self.user_manager = UserManager(self)
     self.lights = Lights(self)
     self.pad = Pad(self)
     self.musiq = Musiq(self)
     self.network_info = NetworkInfo(self)
示例#4
0
    def __init__(self, base: "Base"):
        self.base = base

        self.voting_system = Settings.get_setting("voting_system",
                                                  "False") == "True"
        self.logging_enabled = Settings.get_setting("logging_enabled",
                                                    "True") == "True"
        self.online_suggestions = (Settings.get_setting(
            "online_suggestions", "True") == "True")
        self.number_of_suggestions = int(
            Settings.get_setting("number_of_suggestions", "20"))
        self.people_to_party = int(Settings.get_setting(
            "people_to_party", "3"))
        self.alarm_probability = float(
            Settings.get_setting("alarm_probability", "0"))
        self.downvotes_to_kick = int(
            Settings.get_setting("downvotes_to_kick", "2"))
        self.max_download_size = int(
            Settings.get_setting("max_download_size", "10"))
        self.max_playlist_items = int(
            Settings.get_setting("max_playlist_items", "10"))
        self._check_internet()
示例#5
0
    def __init__(self, base: "Base"):
        self.base = base

        self.youtube_enabled = Settings.get_setting("youtube_enabled",
                                                    "True") == "True"
        self.youtube_suggestions = int(
            Settings.get_setting("youtube_suggestions", "2"))

        self.spotify_enabled = (Settings.get_setting("spotify_enabled",
                                                     "False") == "True")
        self.spotify_suggestions = int(
            Settings.get_setting("spotify_suggestions", "2"))
        self.spotify_username = Settings.get_setting("spotify_username", "")
        self.spotify_password = Settings.get_setting("spotify_password", "")
        self.spotify_client_id = Settings.get_setting("spotify_client_id", "")
        self.spotify_client_secret = Settings.get_setting(
            "spotify_client_secret", "")

        self.soundcloud_enabled = (Settings.get_setting(
            "soundcloud_enabled", "False") == "True")
        self.soundcloud_suggestions = int(
            Settings.get_setting("soundcloud_suggestions", "2"))
        self.soundcloud_auth_token = Settings.get_setting(
            "soundcloud_auth_token", "")
示例#6
0
 def __init__(self, base: "Base"):
     self.base = base
     self.backup_stream = Settings.get_setting("backup_stream", "")
     self.bluetoothctl: Optional[subprocess.Popen[bytes]] = None
     self.bluetooth_devices: List[Dict[str, str]] = []
示例#7
0
    def __init__(self, base: "Base"):
        self.base = base

        self.local_enabled = os.path.islink(Library.get_library_path())

        # in the docker container all dependencies are installed
        self.youtube_available = (settings.DOCKER
                                  or importlib.util.find_spec("youtube_dl")
                                  is not None)
        # the _enabled check is the second expression so the databes entry gets created in any case
        self.youtube_enabled = (Settings.get_setting("youtube_enabled", "True")
                                == "True" and self.youtube_available)
        self.youtube_suggestions = int(
            Settings.get_setting("youtube_suggestions", "2"))

        # Spotify has no python dependencies we could easily check.
        try:
            self.spotify_available = (
                settings.DOCKER or "[spotify]" in subprocess.check_output(
                    ["mopidy", "config"],
                    stderr=subprocess.DEVNULL).decode().splitlines())
        except FileNotFoundError:
            # mopidy is not installed. Disable when mocking, enable otherwise
            self.spotify_available = not settings.MOCK
        self.spotify_enabled = (Settings.get_setting(
            "spotify_enabled", "False") == "True" and self.spotify_available)
        self.spotify_suggestions = int(
            Settings.get_setting("spotify_suggestions", "2"))
        self.spotify_username = Settings.get_setting("spotify_username", "")
        self.spotify_password = Settings.get_setting("spotify_password", "")
        self.spotify_client_id = Settings.get_setting("spotify_client_id", "")
        self.spotify_client_secret = Settings.get_setting(
            "spotify_client_secret", "")

        self.soundcloud_available = (settings.DOCKER
                                     or importlib.util.find_spec("soundcloud")
                                     is not None)
        self.soundcloud_enabled = (Settings.get_setting(
            "soundcloud_enabled", "False") == "True"
                                   and self.soundcloud_available)
        self.soundcloud_suggestions = int(
            Settings.get_setting("soundcloud_suggestions", "2"))
        self.soundcloud_auth_token = Settings.get_setting(
            "soundcloud_auth_token", "")