Module src.utils

This file is responsible for all the helper functions that are used

Expand source code
"""
This file is responsible for all the helper functions that are used
"""
from youtubesearchpython import VideosSearch
from src.get_all import filtered_songs

"""
This function seaches the song on youtube and returns the URL
"""
def searchSong(name_song):
    videosSearch = VideosSearch(name_song, limit=1)
    result = videosSearch.result()
    link = result['result'][0]['link']
    return link


all_songs = filtered_songs()[["title", "artist", "top genre"]]

"""
This function returns random 10 songs for generating the poll for the user
"""
def random_25():
    ten_random_songs = (all_songs.sample(
        frac=1).groupby('top genre').head(1)).sample(25)
    return ten_random_songs

Global variables

var all_songs

This function returns random 10 songs for generating the poll for the user

Functions

def random_25()
Expand source code
def random_25():
    ten_random_songs = (all_songs.sample(
        frac=1).groupby('top genre').head(1)).sample(10)
    return ten_random_songs
def searchSong(name_song)
Expand source code
def searchSong(name_song):
    videosSearch = VideosSearch(name_song, limit=1)
    result = videosSearch.result()
    link = result['result'][0]['link']
    return link