def download_song(vidid): download = system.call_silently( "youtube-dl --extract-audio --audio-format mp3 --id http://youtube.com/watch?v=" + vidid, sync=False ) print("Please fill in some info: ") artist = inputs.get_string(prompt="Artist: ") album = inputs.get_string(prompt="Album: ") title = inputs.get_string(prompt="Title: ") # heel lelijk, moet veranderd worden musicdir = song.get_music_dirs()[0] if len(song.get_music_dirs()) > 1: musicdir = inputs.get_item_from_list(music_conf.MUSIC_DIRS) if not os.path.isdir(musicdir + "/" + artist): os.mkdir(musicdir + "/" + artist) if not os.path.isdir(musicdir + "/" + artist + "/" + album): os.mkdir(musicdir + "/" + artist + "/" + album) download.wait() file_path = musicdir + "/" + artist + "/" + album + "/" + title + ".mp3" os.rename(vidid + ".mp3", file_path) audio = EasyID3(file_path) audio["title"] = title audio["artist"] = artist audio["album"] = album audio.save()
def execute(self, operand): self.debug("Reminding " + operand) cmd = "play " + self.get_resource_path('ding.mp3') system.call_silently(cmd, sync=True) speech.say("Sir, " + operand, sync=False) response = inputs.get_string_timeout(self.get_config('TIME_OUT')) if not response: self.reschedule(operand) if meaning.means(response, "okay"): return elif meaning.means(response, "not_okay"): self.debug("Reminding again in one day.") reschedule_str = inputs.get_string("Schedule again in: ") try: delta = parse.time_delta(reschedule_str) except exceptions.PAULAParseException as e: outputs.print_error(str(e.__class__)) # fix bash issues again operand = operand.replace("\"", "\\\"") operand = operand.replace("\'", "\\\'") schedule.schedule_event_with_delta(delta, "paula_remind", operand) else: self.reschedule(operand)
def execute(self, operand): speech.say("How long do you think you will be gone, Sir?") answer = inputs.get_string() delta = parse.time_delta(answer) speech.say_all_from_file(self.get_resource_path('greetings.paula_says'), sync=True) sleep.go_to_sleep_mode(delta.seconds) answer = inputs.get_string_timeout(self.get_config('WAITING_TIME')) if not answer: sleep.go_to_sleep_mode(0) else: speech.say("Welcome back, Sir")
def execute(self, operand): search_string = operand self.debug("The search string: " + search_string) local_song = song.find_song(search_string) if local_song: self.debug("Found local song!") local_song.play() return #We didn't find it locally; check youtube! vid_id, name = youtube.search_first_hit(search_string) youtube.play_song(vid_id, name) if self.get_config('ASK_DOWNLOAD'): print("Do you want to download this song?") answer = inputs.get_string() if meaning.means(answer, "yes"): youtube.download_song(vid_id)