66# pip install youtube-transcript-api # also present in nixpkgs by the same name
77
88PLAYER=" ${1:- spotify} "
9- FIREFOX=~ /.zen/hbvavekk.School /sessionstore-backups/recovery.jsonlz4
9+ FIREFOX=$( sh -c ' ls $HOME /.zen/*.Default\ Profile /sessionstore-backups/recovery.jsonlz4' )
1010CACHE_DIR=$HOME /.cache/lyrics
1111LOCK_DIR=$HOME /.cache/lyrics/locks
1212mkdir -p " $CACHE_DIR "
@@ -18,7 +18,7 @@ get_id() {
1818 if [[ " $url " =~ ^https://www\. youtube\. com/watch\? v= ]]; then
1919 echo " $url " | perl -pe ' s|https:\/\/www\.youtube\.com\/watch\?v=||'
2020 else
21- echo " Error: The URL is not from YouTube." >&2
21+ # echo "Error: The URL is not from YouTube." >&2
2222 return 1
2323 fi
2424}
@@ -229,14 +229,14 @@ youtube() {
229229
230230 print(convert_json_to_timestamp_format(t), end='\n')
231231EOF
232- )
233- if [ $? -eq 0 ]; then
234- echo " $res " > " $file_path "
235- fi
232+ )
233+ if [ $? -eq 0 ]; then
234+ echo " $res " > " $file_path "
235+ fi
236236
237- # Release the lock
238- release_lock " $lock_name "
239- echo " $res "
237+ # Release the lock
238+ release_lock " $lock_name "
239+ echo " $res "
240240 fi
241241}
242242
@@ -252,34 +252,34 @@ handle_player() {
252252 fi
253253
254254 case " $player " in
255- spotify | spotifyd | spotify_player)
256- PLAYER=$player
257- if ! lrclib | current_line " $( get_position) " ; then
258- playerctl metadata --format " {{title}} - {{artist}}"
259- fi
260- ;;
261- chromium)
262- PLAYER=chromium
263- album=$( playerctl -p $PLAYER metadata xesam:album | tr -d ' \n' )
264- if [ -z " $album " ]; then
265- playerctl -p $PLAYER metadata --format " {{title}} {{artist}}"
266- else
267- lrclib | current_line " $( get_position) "
268- fi
269- ;;
270- firefox)
271- PLAYER=firefox
272- album=$( playerctl -p $PLAYER metadata xesam:album | tr -d ' \n' )
273- if [ -z " $album " ]; then
274- id=$( get_id)
275- if [ $? -eq 0 ]; then
276- subs=$( youtube " $id " )
277- echo " $subs " | current_line " $( get_position) "
278- fi
279- else
280- lrclib | current_line " $( get_position) "
255+ spotify | spotifyd | spotify_player)
256+ PLAYER=$player
257+ if ! lrclib | current_line " $( get_position) " ; then
258+ playerctl metadata --format " {{title}} - {{artist}}"
259+ fi
260+ ;;
261+ chromium)
262+ PLAYER=chromium
263+ album=$( playerctl -p $PLAYER metadata xesam:album | tr -d ' \n' )
264+ if [ -z " $album " ]; then
265+ playerctl -p $PLAYER metadata --format " {{title}} {{artist}}"
266+ else
267+ lrclib | current_line " $( get_position) "
268+ fi
269+ ;;
270+ firefox)
271+ PLAYER=firefox
272+ album=$( playerctl -p $PLAYER metadata xesam:album | tr -d ' \n' )
273+ if [ -z " $album " ]; then
274+ id=$( get_id)
275+ if [ $? -eq 0 ]; then
276+ subs=$( youtube " $id " )
277+ echo " $subs " | current_line " $( get_position) "
281278 fi
282- ;;
279+ else
280+ lrclib | current_line " $( get_position) "
281+ fi
282+ ;;
283283 esac
284284}
285285
0 commit comments