Skip to content

Commit

Permalink
New icon for explicit songs.
Browse files Browse the repository at this point in the history
It is now easier to differentiate between explicit and non-explicit songs. The queue now includes both if a song is explicit and the songs length.
  • Loading branch information
ZingyTomato committed Jun 1, 2022
1 parent 8225267 commit 2472fca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
15 changes: 11 additions & 4 deletions harmony/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ def queueIsEmpty():

def fixFormatting(text):
inital_text = html.unescape(f'{text}')
final_text = re.sub("[\"\']", " ", inital_text)
final_text = re.sub("[\"\']", "", inital_text)
return final_text

def isExplicit(value):
if value == 1:
explicit = colored("🅴", 'green')
return explicit
else:
return ""

def emptyInput():
print(colored("\nPlease enter the name of a song!", 'red', attrs=['bold']))
return
Expand All @@ -93,7 +100,7 @@ def showQueue():

def showResults(query, result):
info = print(colored("Results for", 'red') + colored(f" {query}\n", 'cyan', attrs=['bold']))
lists = print(f"\n".join([f"{colored(i, 'green')}. {colored(fixFormatting(item['name']), 'red', attrs=['bold'])} - {colored(fixFormatting(item['artist']), 'cyan', attrs=['bold'])} ({time.strftime('%M:%S',time.gmtime(int(item['duration'])))})" for i, item in enumerate((result['results']), start=1)]))
lists = print(f"\n".join([f"{colored(i, 'green')}. {colored(fixFormatting(item['name']), 'red', attrs=['bold'])} - {colored(fixFormatting(item['primaryArtists']), 'cyan', attrs=['bold'])} ({time.strftime('%M:%S',time.gmtime(int(item['duration'])))}) {isExplicit(int(item['explicitContent']))}" for i, item in enumerate((result['results']), start=1)]))
return songs.pickTrack(query, result)

def showResultsVideos(query, result):
Expand Down Expand Up @@ -168,12 +175,12 @@ def playVideosURL(url):
play_videos = os.system(f"mpv --no-resume-playback {url} ")
return videos.searchVideos()

def addSongs(videoid, title, author):
def addSongs(videoid, title, author, duration, explicit):
print(colored("\nGathering info...", 'green', attrs=['bold']), end="\r")
queue_list.append(videoid)
title_list.append(title)
author_list.append(author)
item_list.append(f"{colored(title, 'red')} - {colored(author, 'cyan')}")
item_list.append(f"{colored(title, 'red')} - {colored(author, 'cyan')} ({duration}) {explicit}")
added = print(colored(f"{fixFormatting(title)} - ", 'cyan') + colored(f"{fixFormatting(author)}", 'red') + colored(" has been added to the queue.", 'green'))
return songs.searchSongs()

Expand Down
8 changes: 6 additions & 2 deletions harmony/songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from termcolor import colored
import functions
import os
import time

def searchSongs():

Expand Down Expand Up @@ -65,5 +66,8 @@ def pickTrack(song, json):

videoid = json['results'][int(option) - 1]['downloadUrl'][4]['link']
title = json['results'][int(option) - 1]['name']
author = json['results'][int(option) - 1]['artist']
return functions.addSongs(videoid, title, author)
author = json['results'][int(option) - 1]['primaryArtists']
duration = time.strftime('%M:%S',time.gmtime(int(json['results'][int(option) - 1]['duration'])))
explicit = functions.isExplicit(json['results'][int(option) - 1]['explicitContent'])

return functions.addSongs(videoid, title, author, duration, explicit)
1 change: 1 addition & 0 deletions harmony/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ def pickVideo(video, json):
videoid = json['items'][int(option) - 1]['url']
title = json['items'][int(option) - 1]['title']
author = json['items'][int(option) - 1]['uploaderName']

return functions.addVideos(videoid, title, author)

0 comments on commit 2472fca

Please sign in to comment.