Ejemplo n.º 1
0
    def download_single(self):
        """ Logic behind downloading a song. """

        if self._to_skip():
            return

        # "[number]. [artist] - [song]" if downloading from list
        # otherwise "[artist] - [song]"
        youtube_title = youtube_tools.get_youtube_title(
            self.content, self.number)
        log.info("{} ({})".format(youtube_title, self.content.watchv_url))

        # generate file name of the song to download
        songname = self.refine_songname(self.content.title)

        if const.args.dry_run:
            return

        song_existence = downloader.CheckExists(songname, self.meta_tags)
        if not song_existence.already_exists(self.raw_song):
            down_song = self._download_single(songname)
            if down_song:
                rs.songPusher.put([
                    'track', songname + const.args.output_ext, self.raw_song,
                    self.meta_tags, const.args
                ])
            return down_song
        else:
            rs.songPusher.put([
                'track', songname + const.args.output_ext, self.raw_song,
                self.meta_tags, const.args
            ])
Ejemplo n.º 2
0
def test_check_exists(metadata_fixture, filename_fixture, tmpdir):
    expect_check = False
    const.args.folder = str(tmpdir)
    # prerequisites for determining filename
    track_existence = downloader.CheckExists(filename_fixture, metadata_fixture)
    check = track_existence.already_exists(TRACK_SEARCH)
    assert check == expect_check
def test_check_track_exists_before_download(tmpdir, metadata_fixture, filename_fixture):
    expect_check = False
    const.args.folder = str(tmpdir)
    # prerequisites for determining filename
    track_existence = downloader.CheckExists(filename_fixture, metadata_fixture)
    check = track_existence.already_exists(SPOTIFY_TRACK_URL)
    assert check == expect_check
Ejemplo n.º 4
0
def test_check_track_exists_after_download(metadata_fixture, filename_fixture,
                                           trackpath_fixture):
    expect_check = True
    track_existence = downloader.CheckExists(filename_fixture,
                                             metadata_fixture)
    check = track_existence.already_exists(SPOTIFY_TRACK_URL)
    os.remove(trackpath_fixture + ".mp3")
    assert check == expect_check
Ejemplo n.º 5
0
def test_check_exists(tmpdir):
    expect_check = False
    const.args.folder = str(tmpdir)
    # prerequisites for determining filename
    global file_name
    file_name = internals.sanitize_title(title)
    track_existence = downloader.CheckExists(file_name, metadata)
    check = track_existence.already_exists(TRACK_SEARCH)
    assert check == expect_check
def test_check_track_exists_before_download(tmpdir):
    expect_check = False
    const.args.folder = str(tmpdir)
    # prerequisites for determining filename
    songname = internals.format_string(const.args.file_format, meta_tags)
    global file_name
    file_name = internals.sanitize_title(songname)
    track_existence = downloader.CheckExists(file_name, meta_tags)
    check = track_existence.already_exists(TRACK_URL)
    assert check == expect_check
def test_check_track_exists_after_download():
    expect_check = True
    track_existence = downloader.CheckExists(file_name, meta_tags)
    check = track_existence.already_exists(TRACK_URL)
    os.remove(track_path + ".mp3")
    assert check == expect_check