taslim19
commited on
Commit
·
dc00de0
1
Parent(s):
d30beef
Use tempfile.gettempdir() for downloads in Telegram.py to avoid permission errors
Browse files
DragMusic/platforms/Telegram.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import asyncio
|
2 |
import os
|
3 |
import time
|
|
|
4 |
from typing import Union
|
5 |
|
6 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Voice
|
@@ -80,7 +81,7 @@ class TeleAPI:
|
|
80 |
)
|
81 |
except:
|
82 |
file_name = audio.file_unique_id + "." + "ogg"
|
83 |
-
file_name = os.path.join(
|
84 |
if video:
|
85 |
try:
|
86 |
file_name = (
|
@@ -88,7 +89,7 @@ class TeleAPI:
|
|
88 |
)
|
89 |
except:
|
90 |
file_name = video.file_unique_id + "." + "mp4"
|
91 |
-
file_name = os.path.join(
|
92 |
return file_name
|
93 |
|
94 |
async def download(self, _, message, mystic, fname):
|
|
|
1 |
import asyncio
|
2 |
import os
|
3 |
import time
|
4 |
+
import tempfile
|
5 |
from typing import Union
|
6 |
|
7 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Voice
|
|
|
81 |
)
|
82 |
except:
|
83 |
file_name = audio.file_unique_id + "." + "ogg"
|
84 |
+
file_name = os.path.join(tempfile.gettempdir(), file_name)
|
85 |
if video:
|
86 |
try:
|
87 |
file_name = (
|
|
|
89 |
)
|
90 |
except:
|
91 |
file_name = video.file_unique_id + "." + "mp4"
|
92 |
+
file_name = os.path.join(tempfile.gettempdir(), file_name)
|
93 |
return file_name
|
94 |
|
95 |
async def download(self, _, message, mystic, fname):
|
DragMusic/plugins/games/whois.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
import base64
|
2 |
import requests
|
|
|
3 |
from pyrogram import filters
|
4 |
from DragMusic import app
|
5 |
|
6 |
-
API_URL = "http://aizensolo.ru/"
|
7 |
API_TOKEN = "TEST-API-TOKEN"
|
8 |
|
9 |
@app.on_message(filters.command("whois") & filters.reply)
|
@@ -11,8 +12,11 @@ async def whois_character(client, message):
|
|
11 |
if not message.reply_to_message or not (message.reply_to_message.photo or message.reply_to_message.document):
|
12 |
return await message.reply("Reply to an image to identify the character.")
|
13 |
|
14 |
-
file
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
data = {
|
18 |
'api_token': API_TOKEN,
|
|
|
1 |
import base64
|
2 |
import requests
|
3 |
+
import tempfile
|
4 |
from pyrogram import filters
|
5 |
from DragMusic import app
|
6 |
|
7 |
+
API_URL = "http://aizensolo.ru/getName"
|
8 |
API_TOKEN = "TEST-API-TOKEN"
|
9 |
|
10 |
@app.on_message(filters.command("whois") & filters.reply)
|
|
|
12 |
if not message.reply_to_message or not (message.reply_to_message.photo or message.reply_to_message.document):
|
13 |
return await message.reply("Reply to an image to identify the character.")
|
14 |
|
15 |
+
# Use a temporary file for download
|
16 |
+
with tempfile.NamedTemporaryFile(suffix=".jpg") as temp_file:
|
17 |
+
await message.reply_to_message.download(file_name=temp_file.name)
|
18 |
+
temp_file.seek(0)
|
19 |
+
encoded_string = base64.b64encode(temp_file.read())
|
20 |
|
21 |
data = {
|
22 |
'api_token': API_TOKEN,
|
DragMusic/plugins/management/editwatch.py
CHANGED
@@ -9,7 +9,7 @@ from config import MONGO_DB_URI
|
|
9 |
|
10 |
# MongoDB setup
|
11 |
mongo = MongoClient(MONGO_DB_URI)
|
12 |
-
db = mongo["
|
13 |
group_col = db["editwatch_groups"]
|
14 |
auth_col = db["editwatch_auth_users"]
|
15 |
|
|
|
9 |
|
10 |
# MongoDB setup
|
11 |
mongo = MongoClient(MONGO_DB_URI)
|
12 |
+
db = mongo["AnonX"]
|
13 |
group_col = db["editwatch_groups"]
|
14 |
auth_col = db["editwatch_auth_users"]
|
15 |
|
DragMusic/plugins/play/play.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import random
|
2 |
import string
|
|
|
|
|
3 |
|
4 |
from pyrogram import filters
|
5 |
from pyrogram.types import InlineKeyboardMarkup, InputMediaPhoto, Message
|
@@ -551,4 +553,24 @@ async def play_playlists_command(client, CallbackQuery, _):
|
|
551 |
_["play_2"].format(channel) if channel else _["play_1"]
|
552 |
)
|
553 |
videoid = lyrical.get(videoid)
|
554 |
-
video =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import random
|
2 |
import string
|
3 |
+
import tempfile
|
4 |
+
import os
|
5 |
|
6 |
from pyrogram import filters
|
7 |
from pyrogram.types import InlineKeyboardMarkup, InputMediaPhoto, Message
|
|
|
553 |
_["play_2"].format(channel) if channel else _["play_1"]
|
554 |
)
|
555 |
videoid = lyrical.get(videoid)
|
556 |
+
video = True if mode == "v" else None
|
557 |
+
ffplay = True if fplay == "f" else None
|
558 |
+
try:
|
559 |
+
await stream(
|
560 |
+
_,
|
561 |
+
mystic,
|
562 |
+
CallbackQuery.from_user.id,
|
563 |
+
details,
|
564 |
+
chat_id,
|
565 |
+
user_name,
|
566 |
+
CallbackQuery.message.chat.id,
|
567 |
+
video,
|
568 |
+
streamtype="youtube",
|
569 |
+
forceplay=ffplay,
|
570 |
+
)
|
571 |
+
except Exception as e:
|
572 |
+
print(f"Error: {e}")
|
573 |
+
ex_type = type(e).__name__
|
574 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
575 |
+
return await mystic.edit_text(err)
|
576 |
+
return await mystic.delete()
|