Example #1
0
    def get_pandora_client(self):
        cfg_file = os.environ.get("PYDORA_CFG", "")
        builder = clientbuilder.PydoraConfigFileBuilder(cfg_file)
        if builder.file_exists:
            return builder.build()

        builder = clientbuilder.PianobarConfigFileBuilder()
        if builder.file_exists:
            return builder.build()

        logger.info("No valid pandora config found.")
        sys.exit(1)
Example #2
0
    def get_client(self):
        cfg_file = os.environ.get("PYDORA_CFG", "")
        builder = clientbuilder.PydoraConfigFileBuilder(cfg_file)
        if builder.file_exists:
            return builder.build()

        builder = clientbuilder.PianobarConfigFileBuilder()
        if builder.file_exists:
            return builder.build()

        if not self.client:
            Screen.print_error("No valid config found")
            sys.exit(1)
Example #3
0
    def _start(self):
        """
        @see Startable._start()
        """
        builder = clientbuilder.PydoraConfigFileBuilder('')
        if not builder.file_exists:
            raise ValueError("Unable to find config file; "
                             "have you run pydora-config yet?")

        self._pandora = builder.build()
        LOG.info("Configured as device %s", self._pandora.device)

        self._player = VLCPlayer(Callbacks(self), sys.stdin)
        self._player.start()
    def test_integration(self):
        path = os.path.join(os.path.dirname(__file__), "pydora.cfg")
        cfg = cb.PydoraConfigFileBuilder(path).parse_config()

        self.assertDictEqual(cfg, {
            "AUDIO_QUALITY": "test_quality",
            "DECRYPTION_KEY": "test_decryption_key",
            "DEVICE": "test_device",
            "ENCRYPTION_KEY": "test_encryption_key",
            "PARTNER_PASSWORD": "******",
            "PARTNER_USER": "******",
            "API_HOST": "test_host",
            "USER": {
                "USERNAME": "******",
                "PASSWORD": "******",
                }
            })
Example #5
0
    def crawl(self):
        log("Getting Liked Songs for %s\n" % self.username)

        builder = clientbuilder.PydoraConfigFileBuilder(self.cfg_file)
        client = builder.build()
        slist = client.get_station_list()

        stations = []

        for i, s in enumerate(slist):
            stations.append(s.token)

        for station in stations:
            station_detail = client.get_station(station)

            if not hasattr(station_detail, "feedback"):
                continue
            if station_detail.feedback:

                likes = station_detail.feedback.get('thumbsUp')

                if likes:
                    for item in likes:
                        station_name = unidecode.unidecode(station_detail.name)
                        source = "Pandora.Liked.%s.%s" % (self.username,
                                                          station_name)
                        title = unidecode.unidecode(item['songName'])
                        artist = unidecode.unidecode(item['artistName'])
                        raw_album = item.get('albumName')
                        if raw_album:
                            album = unidecode.unidecode(raw_album)
                        else:
                            album = ""
                        art_url = unidecode.unidecode(item['albumArtUrl'])
                        song = database.SongRow(title=title,
                                                artist=artist,
                                                album=album,
                                                artwork=art_url,
                                                source=source,
                                                status="Added")

                        self.songs.add(song, log_new=True, log_dup=False)
                        if not self.quiet:
                            log("\tFound Liked Song: %s" % song.name())