From: Chris Fulljames Date: Sun, 2 Mar 2025 19:14:32 +0000 (-0500) Subject: Prevent my songs from showing up at top of random page X-Git-Url: https://littlesong.place/gitweb/gitweb.cgi?a=commitdiff_plain;h=ff9e717cbfc928b18e9099b598beede350c0f863;p=littlesongplace.git Prevent my songs from showing up at top of random page --- diff --git a/main.py b/main.py index 2007410..6103b4d 100644 --- a/main.py +++ b/main.py @@ -1090,8 +1090,18 @@ class Song: @classmethod def get_random(cls, count): - songs = cls._from_db("select * from songs inner join users on songs.userid = users.userid where songid in (select songid from songs order by random() limit ?)", [count]) + # Get random songs + 10 extras so I can filter out my own (I uploaded too many :/) + songs = cls._from_db("select * from songs inner join users on songs.userid = users.userid where songid in (select songid from songs order by random() limit ?)", [count + 10]) random.shuffle(songs) + + # Prevent my songs from showing up in the first 10 results + for i in reversed(range(min(10, len(songs)))): + if songs[i].username == "cfulljames": + del songs[i] + + # Drop any extra songs (since we asked for 10 extras) + songs = songs[:count] + return songs @classmethod diff --git a/todo.txt b/todo.txt index 66208ad..2177b71 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ NOW +- Hide shuffle button for song lists with 1 song or fewer - Pinned profile playlists - Player minimize button