diff --git a/core/__init__.py b/core/__init__.py index a96857b..eb4143d 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -18,7 +18,7 @@ from core.song import Song from core.admins import is_sudo, is_admin -from core.stream import app, ydl, safone, pytgcalls, start_stream +from core.stream import app, ytdl, safone, pytgcalls, start_stream from core.groups import ( get_group, get_queue, set_group, set_title, all_groups, clear_queue, set_default, shuffle_queue) diff --git a/core/stream.py b/core/stream.py index c6254ac..d16164a 100644 --- a/core/stream.py +++ b/core/stream.py @@ -37,8 +37,14 @@ "geo_bypass": True, "nocheckcertificate": True, } -ydl = YoutubeDL(ydl_opts) -app = Client(config.SESSION, api_id=config.API_ID, api_hash=config.API_HASH) +app = Client( + "MusicPlayerUB", + api_id=config.API_ID, + api_hash=config.API_HASH, + session_string=config.SESSION, + in_memory=True, +) +ytdl = YoutubeDL(ydl_opts) pytgcalls = PyTgCalls(app) diff --git a/main.py b/main.py index d98c81a..2bdb778 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ from pytgcalls.types.stream import StreamAudioEnded, StreamVideoEnded from core.decorators import language, register, only_admins, handle_error from core import ( - app, ydl, safone, search, is_sudo, is_admin, get_group, get_queue, + app, ytdl, safone, search, is_sudo, is_admin, get_group, get_queue, pytgcalls, set_group, set_title, all_groups, clear_queue, check_yt_url, extract_args, start_stream, shuffle_queue, delete_messages, get_spotify_playlist, get_youtube_playlist) @@ -47,6 +47,7 @@ api_id=config.API_ID, api_hash=config.API_HASH, bot_token=config.BOT_TOKEN, + in_memory=True, ) client = bot else: @@ -135,7 +136,7 @@ async def live_stream(_, message: Message, lang): else: is_yt_url, url = check_yt_url(args) if is_yt_url: - meta = ydl.extract_info(url, download=False) + meta = ytdl.extract_info(url, download=False) formats = meta.get("formats", [meta]) for f in formats: ytstreamlink = f["url"] diff --git a/startup.sh b/startup.sh index 52d7b42..80ba325 100644 --- a/startup.sh +++ b/startup.sh @@ -1,8 +1,17 @@ +#!/bin/bash + echo ">> FETCHING UPSTREAM..." -git clone -b dev https://github.com/AsmSafone/MusicPlayer /MusicPlayer +if [ -d "/MusicPlayer" ]; then + echo "Directory exists. Pulling the latest changes..." + cd /MusicPlayer && git pull +else + echo "Directory does not exist. Cloning the repository..." + git clone -b dev https://github.com/AsmSafone/MusicPlayer /MusicPlayer + echo ">> INSTALLING REQUIREMENTS..." cd /MusicPlayer pip3 install -U -r requirements.txt + echo ">> STARTING MUSIC PLAYER USERBOT..." clear echo "