taslim19 commited on
Commit
90dc4ea
Β·
1 Parent(s): 80b8447

revert back to old version of the dsong.py

Browse files
DragMusic/plugins/plugins/dsong.py CHANGED
@@ -25,10 +25,10 @@ async def vsong_cmd(client, message):
25
  url = bitflow["url"]
26
  title = bitflow.get("title", "Unknown")
27
  duration = bitflow.get("duration", 0)
 
 
28
  thumb = bitflow.get("thumbnail", None)
29
  ext = bitflow.get("ext", "mp4")
30
- if ext.lower() != "mp4":
31
- return await infomsg.edit("❌ Only MP4 video format is supported. Try another video.")
32
  except Exception as error:
33
  return await infomsg.edit(f"<b>πŸ” Searching...\n\n{error}</b>")
34
 
@@ -57,6 +57,8 @@ async def vsong_cmd(client, message):
57
  f"<blockquote><b> Information {title}</b></blockquote>\n\n"
58
  f"<blockquote><b> Name:</b> {title}\n"
59
  f"<b> Duration:</b> {timedelta(seconds=duration)}\n"
 
 
60
  f"<b> Link:</b> <a href='{url}'>YouTube</a></blockquote>\n\n"
61
  f"<blockquote><b>⚑ Powered by: @dragbotsupport</b></blockquote> "
62
  ),
@@ -85,10 +87,10 @@ async def song_cmd(client, message):
85
  url = bitflow["url"]
86
  title = bitflow.get("title", "Unknown")
87
  duration = bitflow.get("duration", 0)
 
 
88
  thumb = bitflow.get("thumbnail", None)
89
  ext = bitflow.get("ext", "mp3")
90
- if ext.lower() != "mp3":
91
- return await infomsg.edit("❌ Only MP3 audio format is supported. Try another song.")
92
  except Exception as error:
93
  return await infomsg.edit(f"<b>πŸ” Searching...\n\n{error}</b>")
94
 
@@ -112,11 +114,14 @@ async def song_cmd(client, message):
112
  audio=file_path,
113
  thumb=thumbnail_path,
114
  title=title,
 
115
  duration=duration,
116
  caption=(
117
  f"<blockquote><b> Information {title}</b></blockquote>\n\n"
118
  f"<blockquote><b> Name:</b> {title}\n"
119
  f"<b> Duration:</b> {timedelta(seconds=duration)}\n"
 
 
120
  f"<b> Link:</b> <a href='{url}'>YouTube</a></blockquote>\n\n"
121
  f"<blockquote><b>⚑ Powered by: @dragbotsupport</b></blockquote>"
122
  ),
 
25
  url = bitflow["url"]
26
  title = bitflow.get("title", "Unknown")
27
  duration = bitflow.get("duration", 0)
28
+ views = bitflow.get("views", 0)
29
+ channel = bitflow.get("channel", "Unknown")
30
  thumb = bitflow.get("thumbnail", None)
31
  ext = bitflow.get("ext", "mp4")
 
 
32
  except Exception as error:
33
  return await infomsg.edit(f"<b>πŸ” Searching...\n\n{error}</b>")
34
 
 
57
  f"<blockquote><b> Information {title}</b></blockquote>\n\n"
58
  f"<blockquote><b> Name:</b> {title}\n"
59
  f"<b> Duration:</b> {timedelta(seconds=duration)}\n"
60
+ f"<b> Views:</b> {views:,}\n"
61
+ f"<b> Channel:</b> {channel}\n"
62
  f"<b> Link:</b> <a href='{url}'>YouTube</a></blockquote>\n\n"
63
  f"<blockquote><b>⚑ Powered by: @dragbotsupport</b></blockquote> "
64
  ),
 
87
  url = bitflow["url"]
88
  title = bitflow.get("title", "Unknown")
89
  duration = bitflow.get("duration", 0)
90
+ views = bitflow.get("views", 0)
91
+ channel = bitflow.get("channel", "Unknown")
92
  thumb = bitflow.get("thumbnail", None)
93
  ext = bitflow.get("ext", "mp3")
 
 
94
  except Exception as error:
95
  return await infomsg.edit(f"<b>πŸ” Searching...\n\n{error}</b>")
96
 
 
114
  audio=file_path,
115
  thumb=thumbnail_path,
116
  title=title,
117
+ performer=channel,
118
  duration=duration,
119
  caption=(
120
  f"<blockquote><b> Information {title}</b></blockquote>\n\n"
121
  f"<blockquote><b> Name:</b> {title}\n"
122
  f"<b> Duration:</b> {timedelta(seconds=duration)}\n"
123
+ f"<b> Views:</b> {views:,}\n"
124
+ f"<b> Channel:</b> {channel}\n"
125
  f"<b> Link:</b> <a href='{url}'>YouTube</a></blockquote>\n\n"
126
  f"<blockquote><b>⚑ Powered by: @dragbotsupport</b></blockquote>"
127
  ),
DragMusic/plugins/plugins/jplay.py DELETED
@@ -1,86 +0,0 @@
1
- import os
2
- import tempfile
3
- import httpx
4
- from datetime import timedelta
5
- from pyrogram import filters
6
- from pyrogram.types import Message
7
- from pyrogram.enums import ParseMode
8
- from DragMusic import app
9
-
10
- JIOSAAVN_API = "https://saavn.dev/api/songs"
11
-
12
- async def fetch_jiosaavn_audio(query):
13
- # Accepts either a JioSaavn link or a search query
14
- # Returns (title, artist, duration, image, audio_url) or None
15
- params = {"query": query}
16
- async with httpx.AsyncClient() as client:
17
- resp = await client.get(JIOSAAVN_API, params=params)
18
- if resp.status_code != 200:
19
- return None
20
- data = resp.json()
21
- if not data or not data.get("data"):
22
- return None
23
- song = data["data"][0]
24
- title = song.get("name")
25
- artist = song.get("primaryArtists")
26
- duration = int(song.get("duration", 0))
27
- image = song.get("image")
28
- audio_url = None
29
- # Find the highest quality audio link
30
- for quality in ["320kbps", "160kbps", "96kbps"]:
31
- if song.get("downloadUrl") and song["downloadUrl"].get(quality):
32
- audio_url = song["downloadUrl"][quality]
33
- break
34
- if not audio_url:
35
- return None
36
- return title, artist, duration, image, audio_url
37
-
38
- @app.on_message(filters.command(["jplay"]))
39
- async def jplay_cmd(client, message: Message):
40
- if len(message.command) < 2:
41
- return await message.reply_text(
42
- "❌ <b>No JioSaavn link or query provided.</b>\nUsage: /jplay <link or song name>",
43
- )
44
- query = message.text.split(None, 1)[1]
45
- infomsg = await message.reply_text("<b>πŸ” Searching JioSaavn...</b>", quote=False)
46
- result = await fetch_jiosaavn_audio(query)
47
- if not result:
48
- return await infomsg.edit("❌ Could not fetch this song from JioSaavn.")
49
- title, artist, duration, image, audio_url = result
50
- temp_dir = tempfile.gettempdir()
51
- file_path = os.path.join(temp_dir, f"{title}.mp3")
52
- try:
53
- await infomsg.edit("<b>Downloading audio from JioSaavn...</b>")
54
- async with httpx.AsyncClient() as client:
55
- r = await client.get(audio_url)
56
- with open(file_path, "wb") as f:
57
- f.write(r.content)
58
- thumb_path = None
59
- if image:
60
- thumb_path = os.path.join(temp_dir, f"{title}_thumb.jpg")
61
- async with httpx.AsyncClient() as client:
62
- r = await client.get(image)
63
- with open(thumb_path, "wb") as f:
64
- f.write(r.content)
65
- await message.reply_audio(
66
- audio=file_path,
67
- thumb=thumb_path,
68
- title=title,
69
- performer=artist,
70
- duration=duration,
71
- caption=(
72
- f"<blockquote><b>JioSaavn Song</b></blockquote>\n\n"
73
- f"<blockquote><b>Name:</b> {title}\n"
74
- f"<b>Artist:</b> {artist}\n"
75
- f"<b>Duration:</b> {timedelta(seconds=duration)}</blockquote>\n\n"
76
- f"<blockquote><b>⚑ Powered by: JioSaavn</b></blockquote>"
77
- ),
78
- parse_mode=ParseMode.HTML,
79
- reply_to_message_id=message.id,
80
- )
81
- finally:
82
- if 'thumb_path' in locals() and thumb_path and os.path.isfile(thumb_path):
83
- os.remove(thumb_path)
84
- if file_path and os.path.isfile(file_path):
85
- os.remove(file_path)
86
- await infomsg.delete()