def lyrics_down(text): text = text.split() text = ' '.join(text[text.index('lyrics') + 1:]) print(text) addr = google.lucky( text + 'lyrics.wikia.com' ) #"http://lyrics.wikia.com/wiki/Twenty_One_Pilots:Ride" res = requests.get(addr) try: res.raise_for_status() except: return 'Downloading Error' soup = bs4.BeautifulSoup(res.text, 'lxml') s = soup.select('.lyricbox') n = soup.select('h1') col = n[0].get_text().find(':') name = n[0].get_text()[:col] + ' ' + n[0].get_text()[col + 1:] print(name) chdir(LYRICS_DIR) lyrics = open(name, 'w') for i in s[0].get_text('\n').split('\n'): #if i == '': lyrics.write('\n') lyrics.write(i) lyrics.close() return open_file(LYRICS_DIR + name)
def lyrics_down(text): text = text.split() text = ' '.join(text[text.index('lyrics') + 1:]) print(text) addr = google.lucky(text + 'lyrics.wikia.com')#"http://lyrics.wikia.com/wiki/Twenty_One_Pilots:Ride" res = requests.get(addr) try: res.raise_for_status() except: notify(message='Error in downloading lyrics') speak('Error in downloading lyrics') soup = bs4.BeautifulSoup(res.text, 'lxml') s = soup.select('.lyricbox') n = soup.select('h1') col = n[0].get_text().find(':') name = n[0].get_text()[:col] + ' ' + n[0].get_text()[col+1:] name=name+".txt" print(name) os.chdir(homeDir+'/Downloads/') lyrics = open(name, 'w') for i in s[0].get_text('\n').split('\n'): lyrics.write('\n') lyrics.write(i) lyrics.close() call(['open','-e',homeDir+'/Downloads/'+name]) speak("Here are your Lyrics")
def google_lucky(message, keyword): """Google I'm feeling lucky.""" r = lucky(keyword) if r: url, desc = r return message.send(u"{} - {}".format(url, desc)) return message.send("Found nothing")
def browseUrl(text): from google import lucky from audioOutput import speak try: url = lucky(text) open_new_tab(url) speak("here it is") except: speak('Something went wrong!!!')
def get_address(text): text = text.split() try: text = ' '.join(text[text.index('browse') + 1:]) except ValueError: text = ' '.join(text[text.index('open') + 1:]) ''' res = requests.get('https://www.google.com/search?q=' + text) res.raise_for_status() soup = bs4.BeautifulSoup(res.text, 'lxml') link = soup.select_one('cite').getText() print(link) ''' return open_link(google.lucky(text))
link = soup.select("#download-btn")[0].get("href") download_song(link, name) print(link) def get_search_results(url): driver = webdriver.Chrome(chromedriver) driver.get(url) soup = BeautifulSoup(driver.page_source, 'lxml') data = soup.select("#searchResults > ul > li > a") song_data = {"name": [], "artist": [], "size": [], "link": []} for song in data: song_data["link"].append(base_url + song.get("href")) song_data["name"].append(song.select("h3")[0].getText()) song_data["artist"].append(song.select("p")[0].getText()) song_data["size"].append(song.select("span")[0].getText()) driver.close() for i in range(len(data)): print("%d | %s | %s | %s" % (i + 1, song_data["name"][i], song_data["artist"][i], song_data["size"][i])) index = int(input("Enter a number : ")) get_down_link(song_data["link"][index], song_data["name"][index]) return data get_search_results( lucky(input("Enter song name : ") + " site:musicpleer.audio"))
def get_answer(question,silent=1): our_q = gen_query(question) query = urllib.quote_plus(our_q) url = lucky("http://www.google.com/search?q="+ query + "&btnI") if silent != 0: return(parse_url(url,our_q))
print(link) def get_search_results(url): driver = webdriver.Chrome(chromedriver) driver.get(url) soup = BeautifulSoup(driver.page_source, 'lxml') data = soup.select("#searchResults > ul > li > a") song_data = {"name": [], "artist": [], "size": [], "link": []} for song in data: song_data["link"].append(base_url + song.get("href")) song_data["name"].append(song.select("h3")[0].getText()) song_data["artist"].append(song.select("p")[0].getText()) song_data["size"].append(song.select("span")[0].getText()) driver.close() for i in range(len(data)): print("%d | %s | %s | %s"%(i+1, song_data["name"][i], song_data["artist"][i], song_data["size"][i])) index = int(input("Enter a number : ")) get_down_link(song_data["link"][index], song_data["name"][index]) return data get_search_results(lucky(input("Enter song name : ") + " site:musicpleer.audio"))
def youtube_link(text): link = lucky(text + ' youtube') vid_download(link)
def resolve(term): return google.lucky('site:astronautix.com ' + term)
def onEvent(self, event): try: if isinstance(event, SkypeNewMessageEvent) and not event.msg.userId == self.userId: text = event.msg.plain.strip() if (text.startswith("!") or text.startswith(".")) and len(text) > 1: # Command text = text[1:] parts = text.split(" ") command = parts[0].lower() if command == "vote" or command == "v": if len(parts) >= 2: if len(parts) < 3: parts.append("1200") self.castVote(event.msg.chat, event.msg.userId, parts[1], parts[2]) else: self.showVoteHelp(event.msg.userId) elif command == "setvote": if len(parts) >= 4 and event.msg.userId == "live:mail_8717": self.castVote(event.msg.chat, parts[1], parts[2], parts[3]) elif command == "g": if len(parts) >= 2: event.msg.chat.setTyping(True) search_string = " ".join(parts[1:]) try: response = google.lucky(search_string, tld="de", only_standard=True) except Exception: logging.exception("Exception") traceback.print_exc() response = "NEIN!" event.msg.chat.sendMsg(response) event.msg.chat.setTyping(False) else: self.getPrivateChat(event.msg.userId).sendMsg("Syntax: !g <query>") elif command == "ask" or command == "a": event.msg.chat.setTyping(True) # if random.choice([True, False]): # response = "JA!" # else: # response = "NEIN!" response = self.eightball() time.sleep(random.random()*2) event.msg.chat.sendMsg(response) event.msg.chat.setTyping(False) elif command == "karte" or command == "k": event.msg.chat.setTyping(True) response = None if len(parts) >= 2: loc = self.getLoc(parts[1]) if loc == 1: response = "http://losteria.de/menu/woche/" if loc == 2: response = "http://bistro-dahlienfeld.de/Portals/0/pdf/SER/aktuelle%20Speisekarte.pdf" if loc in [3]: response = "Unbekannt" if loc == 5: response = "https://www.kamehabonn.de/de/bayrischer-mittags-schmankerl.html" if loc == 6: isocal = datetime.datetime.utcnow().isocalendar() response = "https://www.kamehabonn.de/fileadmin/kameha/Ressources/Speisekarten/Brasserie/Plat_du_jour/Brasserie_Aufsteller_{0}_KW{1}.pdf".format(str(isocal[0]), str(isocal[1])) if response == None: response = "Syntax: !karte <ort>" event.msg.chat.sendMsg(response) event.msg.chat.setTyping(False) elif command == "quit" or command == "q": if event.msg.userId == "live:mail_8717": self.run = False except Exception: logging.exception("Exception") traceback.print_exc()