diff --git a/GUI.py b/GUI.py index b177c64..59659ad 100755 --- a/GUI.py +++ b/GUI.py @@ -63,6 +63,7 @@ def onDouble(self, event): value = widget.get(selection[0]) self.entry.delete(0, END) self.entry.insert(END, value) + self.search() # search button fixed #Function to setup the basic layout of the Graphical User Interface def widgets(self): @@ -74,7 +75,8 @@ def widgets(self): Label(self, text="Song Downloader System", background="#CC0001", font= ("Comic Sans MS",16)).grid(row=0, column=0, padx=20) self.search_var = StringVar() - self.entry = Entry(self, textvariable=self.search_var, width=45) + self.entry = Entry(self, textvariable=self.search_var, width=45) + self.entry.grid(row=1, column=0, sticky=W, padx=20, pady=10) self.b1=Button(self, text='Search', command=self.search) self.b1.grid(row=1, column=1, sticky=W, padx=20, pady=10) @@ -84,7 +86,7 @@ def widgets(self): self.lbox.bind("", self.onDouble) self.lbox2 = Listbox(self, width=45, height=15) - self.lbox2.grid(row=2, column=1, columnspan=6,sticky=W, padx=2000, pady=10) + self.lbox2.grid(row=2, column=1, columnspan=6,sticky=W, padx=20, pady=10) """ diff --git a/crawler.py b/crawler.py index 90a50b8..9825a05 100644 --- a/crawler.py +++ b/crawler.py @@ -188,6 +188,7 @@ def getMetaData(soup, noOfRecords): if(s != None): if(s.has_attr('title')): if(s['title'] == 'Verified'): + d['Verified'] = True pass #Third child of yt-lockup-content division @@ -214,7 +215,7 @@ def toNumber(string): try: return int(number) except: - return -1 + return 0 #Function that filters out the most relevant Youtube video def getMostRelevant(metaData, searchWord): diff --git a/crawler.pyc b/crawler.pyc index ef88d48..253456e 100644 Binary files a/crawler.pyc and b/crawler.pyc differ diff --git a/downloader.py b/downloader.py index e349c38..69bad53 100644 --- a/downloader.py +++ b/downloader.py @@ -9,7 +9,7 @@ def convert_youtubeURL_to_download_URL(youtube_URL): https://www.ssyoutube.com/XXX contains a link which allows music videos to be downloaded. youtube_URL: the URL of the music video to be downloaded """ - index = youtube_URL.find('https') + index = youtube_URL.find('youtube') file_retrieve_URL = youtube_URL[0:index] + 'ss' + youtube_URL[index:] redirect_response = requests.get(file_retrieve_URL) print(redirect_response.url) @@ -60,6 +60,6 @@ def download_video(url, filename): response = requests.get(url, headers=headers) print(response) - file = open(filename, 'wb') + file = open(filename, '.mp4') # in second branch, second commit file.write(response.content) file.close() diff --git a/main.py b/main.py index 4e169ba..b037647 100644 --- a/main.py +++ b/main.py @@ -50,7 +50,7 @@ def initiate_Download(search, relevant): youtube_URL = 'https://www.youtube.com'+relevant['Link'] ssyoutube_URL = convert_youtubeURL_to_download_URL(youtube_URL) file_URL = retrieve_File_URL(ssyoutube_URL) - download_video(file_URL, search) + download_video(file_URL, search+'.mp4') diff --git a/main.pyc b/main.pyc index 148d4ff..cfd6565 100644 Binary files a/main.pyc and b/main.pyc differ diff --git a/song_finder.py b/song_finder.py index a3040ad..9af21d1 100755 --- a/song_finder.py +++ b/song_finder.py @@ -21,7 +21,7 @@ def compareArtists(artists, search): def searchStringLogic(cursor, search_string): words = search_string.split(' ') for i in range(len(words) - 1): - artist = '-'.join(words[0:i]) + artist = '-'.join(words[0:i+1]) song = '-'.join(words[i+1:]) print('Artist', artist) print('Song', song) @@ -32,15 +32,16 @@ def searchStringLogic(cursor, search_string): print(artist_result) return (artist_result, song) - return (None, None) + return (None, None) # test required def getAllSongs(cursor, artist, song): songs = [] - query = "SELECT song, year FROM lyrics WHERE artist LIKE '%s' AND song NOT LIKE '%s';" %(song, artist) + query = "SELECT song, year FROM lyrics WHERE artist LIKE '%s' AND song NOT LIKE '%s';" %(artist, song) cursor.execute(query) rows=cursor.fetchall() for row in rows: print(row[0], row[1]) + print "" songs.append(str(row[0]) + str(row[1])) return songs