Пример #1
0
 def setUp(self):
     self.tag_example_1 = Id3Tag(artist="Pink Floyd", title="Have a cigar", album="Wish you were here",
                                 date=1975, track=3, genre="Progressive rock")
     self.tag_example_2 = Id3Tag(artist="Floyd", title="Cigar", album="Wish you were here",
                                 date=1981, track=2, genre="Rock")
     self.tag_example_3 = Id3Tag(artist="Pink Floyd", title="Cigar", album="Some Other Album",
                                 date=1975, track=3, genre="Progressive rock")
     self.plugin_repository = AudioTagRepository(self.session_provider)
Пример #2
0
 def setUp(self):
     self.id3_tag = Id3Tag(artist="Pink Floyd",
                           title="Have a cigar",
                           album="Wish you were here",
                           date=1975,
                           track=3,
                           genre="Progressive rock")
Пример #3
0
 def from_serializable(cls, serialized: Dict[str, Any]):
     audio_meta_object = CompressedAudioFileMeta.from_serializable(serialized["audio_meta"])
     id3_tag_object = Id3Tag.from_serializable(serialized["id3_tag"])
     plugin_object = VampyPlugin.from_serializable(serialized["plugin"])
     plugin_config_object = VampyPluginParams.from_serializable(serialized["plugin_config"])
     serialized.update({"audio_meta": audio_meta_object, "id3_tag": id3_tag_object,
                        "plugin": plugin_object, "plugin_config": plugin_config_object})
     return AnalysisRequest(**serialized)
Пример #4
0
def _mutagen_tag_to_internal(mutagen_tag: Union[EasyID3, FLAC]) -> Id3Tag:
    maybe_track_number = first_if_collection(mutagen_tag.get("tracknumber"))
    track_number = maybe_track_number.split("/")[0] if maybe_track_number else None
    return Id3Tag(artist=first_if_collection(mutagen_tag["artist"]),
                  title=first_if_collection(mutagen_tag["title"]),
                  album=first_if_collection(mutagen_tag.get("album")),
                  date=safe_cast(first_if_collection(mutagen_tag.get("date")), int, None),
                  track=safe_cast(track_number, int, None),
                  genre=safe_cast(first_if_collection(mutagen_tag.get("genre")), str, None))
Пример #5
0
    def test_should_be_serialized_to_json(self):
        serialized = self.id3_tag.to_serializable()
        serialized_to_json = json.dumps(serialized)
        assert_that(serialized_to_json).is_not_none()

        deserialized_from_json = json.loads(serialized_to_json)
        object_again = Id3Tag.from_serializable(
            serialized=deserialized_from_json)
        assert_that(object_again).is_equal_to(self.id3_tag)
Пример #6
0
 def setUp(self):
     self.audio_meta_example = CompressedAudioFileMeta("some_file.mp3", 1024 * 1024 * 2, 1, 44100, 45., 128.)
     self.id3_tag_example = Id3Tag(artist="Unknown Artist", title="Unknown Title", album="Unknown Album",
                                   date=2017, track=1, genre="Unknown Genre")
     self.example_vampy_plugin = VampyPlugin("vamp-example-plugins", "amplitudefollower", "amplitude",
                                             library_file_name="/root/vamp/vamp-example-plugins.so")
     self.task_id = "fa3b5d8c-b760-49e0-b8b5-7ce0737621d8"
     self.plugin_config_example = VampyPluginParams(block_size=2048, step_size=512)
     self.analysis_request_example = AnalysisRequest(self.task_id, self.audio_meta_example, self.id3_tag_example,
                                                     self.example_vampy_plugin, self.plugin_config_example)
Пример #7
0
 def test_should_show_audio_tags_of_mp3_file(self):
     expected_status_code = 200
     response = requests.get(
         url="{}/{}/tag".format(self.audio_api_url, self.mp3_file_name))
     assert_that(response.status_code).is_equal_to(expected_status_code)
     returned_tag = Id3Tag.from_serializable(response.json())
     assert_that(returned_tag.artist).is_equal_to("Unknown Artist")
     assert_that(returned_tag.title).is_equal_to("Unknown Title")
     assert_that(returned_tag.album).is_equal_to("Unknown Album")
     assert_that(returned_tag.date).is_equal_to(2017)
     assert_that(returned_tag.track).is_equal_to(1)
     assert_that(returned_tag.genre).is_equal_to("Unknown Genre")
 def setUp(self):
     self.mp3_audio_file_name = get_absolute_path_for_project_file(
         __file__, TEST_MP3_AUDIO_FILE)
     self.flac_audio_file_name = get_absolute_path_for_project_file(
         __file__, TEST_FLAC_AUDIO_FILE)
     self.non_existing_file_path = "/tmp/non-existing-file-0"
     self.id3_audio_tag = Id3Tag(artist="Unknown Artist",
                                 title="Unknown Title",
                                 album="Unknown Album",
                                 date=2017,
                                 track=1,
                                 genre="Unknown Genre")
Пример #9
0
 def setUp(self):
     self.task_id = "0f961f20-b036-5740-b526-013523dd88c7"
     self.audio_meta_example_1 = CompressedAudioFileMeta(
         "some_file.mp3", 1024 * 1024 * 2, 1, 44100, 45., 128.)
     self.audio_meta_example_2 = CompressedAudioFileMeta(
         "some_file_2.mp3", 1024 * 1024 * 2, 1, 44100, 45., 128.)
     self.tag_example_1 = Id3Tag(artist="Pink Floyd",
                                 title="Have a cigar",
                                 album="Wish you were here",
                                 date=1975,
                                 track=3,
                                 genre="Progressive rock")
     self.tag_example_2 = Id3Tag(artist="Floyd",
                                 title="Cigar",
                                 album="Wish you were here",
                                 date=1981,
                                 track=2,
                                 genre="Rock")
     self.plugin_example_1 = VampyPlugin("my_vendor", "my_name", "outputs",
                                         "my_file.so")
     self.plugin_example_2 = VampyPlugin("my_vendor", "my_name_2",
                                         "outputs", "my_file_2.so")
     self.plugin_config_example_1 = VampyPluginParams(block_size=2048,
                                                      step_size=1024)
     self.the_request = AnalysisRequest(
         task_id=self.task_id,
         audio_meta=self.audio_meta_example_1,
         id3_tag=self.tag_example_1,
         plugin=self.plugin_example_1,
         plugin_config=self.plugin_config_example_1)
     self.plugin_repo = VampyPluginRepository(self.session_provider)
     self.audio_repo = AudioFileRepository(self.session_provider)
     self.audio_tag_repo = AudioTagRepository(self.session_provider)
     self.plugin_config_repo = PluginConfigRepository(self.session_provider)
     self.request_repo = RequestRepository(self.session_provider,
                                           self.audio_repo,
                                           self.audio_tag_repo,
                                           self.plugin_repo,
                                           self.plugin_config_repo)
Пример #10
0
 def _map_to_object(self, audio_tag: AudioTag) -> Id3Tag:
     return Id3Tag(audio_tag.artist, audio_tag.title, audio_tag.album,
                   audio_tag.date, audio_tag.track, audio_tag.genre)
Пример #11
0
 def test_should_serialize_and_deserialize_id3_tag_object(self):
     serialized = self.id3_tag.to_serializable()
     deserialized = Id3Tag.from_serializable(serialized=serialized)
     assert_that(deserialized).is_equal_to(self.id3_tag)