mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Fixing mobile youtube links and volume returning to 100% when changing songs
This commit is contained in:
parent
2114f15840
commit
45d27b4c47
@ -1,14 +1,14 @@
|
|||||||
from Config.Exceptions import DeezerError, InvalidInput, SpotifyError, VulkanError, YoutubeError
|
from Config.Exceptions import DeezerError, InvalidInput, SpotifyError, VulkanError, YoutubeError
|
||||||
from Music.Downloader import Downloader
|
|
||||||
from Music.Types import Provider
|
|
||||||
from Music.SpotifySearcher import SpotifySearch
|
from Music.SpotifySearcher import SpotifySearch
|
||||||
from Music.DeezerSearcher import DeezerSearcher
|
from Music.DeezerSearcher import DeezerSearcher
|
||||||
from Utils.Utils import Utils
|
|
||||||
from Utils.UrlAnalyzer import URLAnalyzer
|
from Utils.UrlAnalyzer import URLAnalyzer
|
||||||
from Config.Messages import SearchMessages
|
from Config.Messages import SearchMessages
|
||||||
|
from Music.Downloader import Downloader
|
||||||
|
from Music.Types import Provider
|
||||||
|
from Utils.Utils import Utils
|
||||||
|
|
||||||
|
|
||||||
class Searcher():
|
class Searcher:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.__spotify = SpotifySearch()
|
self.__spotify = SpotifySearch()
|
||||||
self.__deezer = DeezerSearcher()
|
self.__deezer = DeezerSearcher()
|
||||||
@ -35,8 +35,7 @@ class Searcher():
|
|||||||
try:
|
try:
|
||||||
musics = self.__spotify.search(track)
|
musics = self.__spotify.search(track)
|
||||||
if musics == None or len(musics) == 0:
|
if musics == None or len(musics) == 0:
|
||||||
raise SpotifyError(self.__messages.SPOTIFY_NOT_FOUND,
|
raise SpotifyError(self.__messages.SPOTIFY_NOT_FOUND, self.__messages.GENERIC_TITLE)
|
||||||
self.__messages.GENERIC_TITLE)
|
|
||||||
|
|
||||||
return musics
|
return musics
|
||||||
except SpotifyError as error:
|
except SpotifyError as error:
|
||||||
@ -79,7 +78,7 @@ class Searcher():
|
|||||||
if not Utils.is_url(track):
|
if not Utils.is_url(track):
|
||||||
return Provider.Name
|
return Provider.Name
|
||||||
|
|
||||||
if "https://www.youtu" in track or "https://youtu.be" in track or "https://music.youtube" in track:
|
if "https://www.youtu" in track or "https://youtu.be" in track or "https://music.youtube" in track or "m.youtube" in track:
|
||||||
return Provider.YouTube
|
return Provider.YouTube
|
||||||
|
|
||||||
if "https://open.spotify.com" in track:
|
if "https://open.spotify.com" in track:
|
||||||
|
|||||||
@ -54,7 +54,9 @@ class ProcessPlayer(Process):
|
|||||||
self.__voiceChannel: VoiceChannel = None
|
self.__voiceChannel: VoiceChannel = None
|
||||||
self.__voiceClient: VoiceClient = None
|
self.__voiceClient: VoiceClient = None
|
||||||
|
|
||||||
|
self.__songVolumeUsing = 1
|
||||||
self.__currentSongChangeVolume = False
|
self.__currentSongChangeVolume = False
|
||||||
|
|
||||||
self.__playing = False
|
self.__playing = False
|
||||||
self.__forceStop = False
|
self.__forceStop = False
|
||||||
self.__botCompletedLoad = False
|
self.__botCompletedLoad = False
|
||||||
@ -120,6 +122,7 @@ class ProcessPlayer(Process):
|
|||||||
print('[PROCESS ERROR] -> Cannot change the volume of this song')
|
print('[PROCESS ERROR] -> Cannot change the volume of this song')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.__songVolumeUsing = volume
|
||||||
self.__voiceClient.source.volume = volume
|
self.__voiceClient.source.volume = volume
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
@ -178,7 +181,7 @@ class ProcessPlayer(Process):
|
|||||||
|
|
||||||
player = FFmpegPCMAudio(song.source, **self.FFMPEG_OPTIONS)
|
player = FFmpegPCMAudio(song.source, **self.FFMPEG_OPTIONS)
|
||||||
if not player.is_opus():
|
if not player.is_opus():
|
||||||
player = PCMVolumeTransformer(player, 1)
|
player = PCMVolumeTransformer(player, self.__songVolumeUsing)
|
||||||
self.__currentSongChangeVolume = True
|
self.__currentSongChangeVolume = True
|
||||||
|
|
||||||
self.__voiceClient.play(player, after=lambda e: self.__playNext(e))
|
self.__voiceClient.play(player, after=lambda e: self.__playNext(e))
|
||||||
|
|||||||
@ -46,6 +46,8 @@ class ThreadPlayer(Thread):
|
|||||||
self.__voiceClient: VoiceClient = None
|
self.__voiceClient: VoiceClient = None
|
||||||
|
|
||||||
self.__currentSongChangeVolume = False
|
self.__currentSongChangeVolume = False
|
||||||
|
self.__songVolumeUsing = 1
|
||||||
|
|
||||||
self.__downloader = Downloader()
|
self.__downloader = Downloader()
|
||||||
self.__callback = callbackToSendCommand
|
self.__callback = callbackToSendCommand
|
||||||
self.__exitCB = exitCB
|
self.__exitCB = exitCB
|
||||||
@ -78,6 +80,7 @@ class ThreadPlayer(Thread):
|
|||||||
print('[THREAD ERROR] -> Cannot change the volume of this song')
|
print('[THREAD ERROR] -> Cannot change the volume of this song')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.__songVolumeUsing = volume
|
||||||
self.__voiceClient.source.volume = volume
|
self.__voiceClient.source.volume = volume
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
@ -136,7 +139,7 @@ class ThreadPlayer(Thread):
|
|||||||
|
|
||||||
player = FFmpegPCMAudio(song.source, **self.FFMPEG_OPTIONS)
|
player = FFmpegPCMAudio(song.source, **self.FFMPEG_OPTIONS)
|
||||||
if not player.is_opus():
|
if not player.is_opus():
|
||||||
player = PCMVolumeTransformer(player, 1)
|
player = PCMVolumeTransformer(player, self.__songVolumeUsing)
|
||||||
self.__currentSongChangeVolume = True
|
self.__currentSongChangeVolume = True
|
||||||
self.__voiceClient.play(player, after=lambda e: self.__playNext(e))
|
self.__voiceClient.play(player, after=lambda e: self.__playNext(e))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user