コード例 #1
0
    def check_file_tags(self):
        mp3s_without_tags = []
        for file in os.listdir(self.path):
            if file.endswith(".mp3"):
                mp3 = MP3(os.path.join(self.path, file))
                if not mp3.has_all_tags():
                    mp3s_without_tags.append(mp3)

        for mp3 in mp3s_without_tags:
            terminal.print_green("\n" + str(mp3s_without_tags.index(mp3) + 1) +
                                 "/" + str(len(mp3s_without_tags)))
            mp3.set_tags()
コード例 #2
0
    def download_videos(self, videos):
        for video in videos:
            terminal.print_green("\n" + str(videos.index(video) + 1) + "/" +
                                 self.count_new_videos)
            terminal.print_green(video.title)

            self.download_video(video)
            try:
                mp3 = MP3(video.path)
                mp3.write_tags({"website": video.url})
            except Exception:
                terminal.print_red("File not existing")

        self.directory.check_file_tags()
コード例 #3
0
    def find_new_videos(self, url):
        videos_in_playlist = scraper.find_videos_in_playlist(
            url, self.directory.path)

        downloaded_files = self.directory.get_downloaded_files()
        terminal.print_green(
            str(len(downloaded_files)) + " files found in directory")

        terminal.print_green(
            str(len(videos_in_playlist)) + " videos found in playlist")

        new_videos = self.directory.find_new_videos(videos_in_playlist,
                                                    downloaded_files)
        self.count_new_videos = str(len(new_videos))

        return new_videos
コード例 #4
0
    def edit(self):
        terminal.print_green("\n" + self.path)
        print("Artist: " + self.read_artist())
        print("Title: " + self.read_title())
        print("URL: " + self.read_url())

        while (True):
            userInput = input()

            if userInput.lower() == "exit" or userInput.lower(
            ) == "quit" or userInput.lower() == "stop" or userInput.lower(
            ) == "end" or userInput == "":
                break

            if self.user_wants_to_edit("artist", userInput):
                self.write_tags({"artist": userInput[7:].strip()})
            elif self.user_wants_to_edit("title", userInput):
                self.write_tags({"title": userInput[6:].strip()})
            elif self.user_wants_to_edit("url", userInput):
                self.write_tags({"website": userInput[4:].strip()})
コード例 #5
0
def main():
    if terminal.get_argument_count() < 3:
        terminal.print_help()
        exit()
    else:
        firstArg = terminal.get_argument(1)
        secondArg = terminal.get_argument(2)

        if firstArg == "help":
            terminal.print_help()
        elif firstArg == "edit":
            MP3(secondArg).edit()
        else:
            downloader = Downloader(secondArg)

            new_videos = downloader.find_new_videos(firstArg)
            terminal.print_green(
                str(len(new_videos)) + " new videos found in playlist")

            downloader.download_videos(new_videos)

            for fail in fails.fails:
                terminal.print_red("failed: " + fail)
コード例 #6
0
    def set_tags(self):
        filename_with_ext = os.path.basename(self.path)
        filename = os.path.splitext(filename_with_ext)[0]

        artist = ""
        title = ""

        terminal.print_green(filename)

        if "-" in filename and filename.count("-") == 1:
            artist = filename[:filename.index("-")].strip()
            print("Artist: " + artist)

            title = filename[filename.index("-") + 1:].strip()
            print("Title: " + title)
        else:
            print("Enter artist name:")
            artist = input()

            print("\nEnter title:")
            title = input()

        self.write_tags({"artist": artist, "title": title})