Skip to content

Commit

Permalink
Fixed mobile URL input and removed Youtube params #357
Browse files Browse the repository at this point in the history
  • Loading branch information
vicwomg committed Aug 7, 2024
1 parent e33aee8 commit 59e0de1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@
from unidecode import unidecode

from lib.file_resolver import FileResolver
from lib.get_platform import (
get_ffmpeg_version,
get_os_version,
get_platform,
is_raspberry_pi,
supports_hardware_h264_encoding,
)
from lib.get_platform import (get_ffmpeg_version, get_os_version, get_platform,
is_raspberry_pi, supports_hardware_h264_encoding)


# Support function for reading lines from ffmpeg stderr without blocking
Expand Down Expand Up @@ -372,8 +367,13 @@ def find_song_by_youtube_id(self, youtube_id):
return None

def get_youtube_id_from_url(self, url):
s = url.split("watch?v=")
if "v=" in url: #accomodates youtube.com/watch?v= and m.youtube.com/?v=
s = url.split("watch?v=")
else: #accomodates youtu.be/
s = url.split("u.be/")
if len(s) == 2:
if "?" in s[1]: #Strip uneeded Youtube Params
s[1] = s[1][0: s[1].index('?')]
return s[1]
else:
logging.error("Error parsing youtube id from url: " + url)
Expand Down

0 comments on commit 59e0de1

Please sign in to comment.