taslim19 commited on
Commit
c025406
·
1 Parent(s): dbf6a24
DragMusic/platforms/Resso.py CHANGED
@@ -12,12 +12,11 @@ class RessoAPI:
12
  self.base = "https://m.resso.com/"
13
 
14
  async def valid(self, link: str):
15
- if re.search(self.regex, link):
16
- return True
17
- else:
18
- return False
19
 
20
  async def track(self, url, playid: Union[bool, str] = None):
 
21
  if playid:
22
  url = self.base + url
23
  async with aiohttp.ClientSession() as session:
@@ -26,6 +25,7 @@ class RessoAPI:
26
  return False
27
  html = await response.text()
28
  soup = BeautifulSoup(html, "html.parser")
 
29
  for tag in soup.find_all("meta"):
30
  if tag.get("property", None) == "og:title":
31
  title = tag.get("content", None)
@@ -33,22 +33,20 @@ class RessoAPI:
33
  des = tag.get("content", None)
34
  try:
35
  des = des.split("·")[0]
36
- except:
37
  pass
38
- if des == "":
39
- return
40
  results = VideosSearch(title, limit=1)
41
- for result in (await results.next())["result"]:
42
- title = result["title"]
43
- ytlink = result["link"]
44
- vidid = result["id"]
45
- duration_min = result["duration"]
46
- thumbnail = result["thumbnails"][0]["url"].split("?")[0]
47
  track_details = {
48
- "title": title,
49
- "link": ytlink,
50
- "vidid": vidid,
51
- "duration_min": duration_min,
52
- "thumb": thumbnail,
53
  }
54
- return track_details, vidid
 
12
  self.base = "https://m.resso.com/"
13
 
14
  async def valid(self, link: str):
15
+ """Check if the link is a valid Resso mobile URL."""
16
+ return bool(re.search(self.regex, link))
 
 
17
 
18
  async def track(self, url, playid: Union[bool, str] = None):
19
+ """Extract track info from a Resso link and find a matching YouTube video."""
20
  if playid:
21
  url = self.base + url
22
  async with aiohttp.ClientSession() as session:
 
25
  return False
26
  html = await response.text()
27
  soup = BeautifulSoup(html, "html.parser")
28
+ title, des = None, None
29
  for tag in soup.find_all("meta"):
30
  if tag.get("property", None) == "og:title":
31
  title = tag.get("content", None)
 
33
  des = tag.get("content", None)
34
  try:
35
  des = des.split("·")[0]
36
+ except Exception:
37
  pass
38
+ if not title or not des:
39
+ return None
40
  results = VideosSearch(title, limit=1)
41
+ yt_results = (await results.next()).get("result", [])
42
+ if not yt_results:
43
+ return None
44
+ result = yt_results[0]
 
 
45
  track_details = {
46
+ "title": result["title"],
47
+ "link": result["link"],
48
+ "vidid": result["id"],
49
+ "duration_min": result["duration"],
50
+ "thumb": result["thumbnails"][0]["url"].split("?")[0],
51
  }
52
+ return track_details, result["id"]
DragMusic/plugins/management/{admins.py → admins.txt} RENAMED
File without changes
DragMusic/plugins/management/{antiflood.py → antiflood.txt} RENAMED
File without changes
DragMusic/plugins/management/{bans.py → bans.txt} RENAMED
File without changes
DragMusic/plugins/management/{waifu_name.py → waifu_name.txt} RENAMED
File without changes
DragMusic/plugins/plugins/dsong.py CHANGED
@@ -48,8 +48,7 @@ async def vsong_cmd(client, message):
48
  with open(thumb_path, "wb") as f:
49
  f.write(r.content)
50
  thumbnail_path = thumb_path
51
- await client.send_video(
52
- message.chat.id,
53
  video=file_path,
54
  thumb=thumbnail_path,
55
  file_name=title,
@@ -112,8 +111,7 @@ async def song_cmd(client, message):
112
  with open(thumb_path, "wb") as f:
113
  f.write(r.content)
114
  thumbnail_path = thumb_path
115
- await client.send_audio(
116
- message.chat.id,
117
  audio=file_path,
118
  thumb=thumbnail_path,
119
  file_name=title,
 
48
  with open(thumb_path, "wb") as f:
49
  f.write(r.content)
50
  thumbnail_path = thumb_path
51
+ await message.reply_video(
 
52
  video=file_path,
53
  thumb=thumbnail_path,
54
  file_name=title,
 
111
  with open(thumb_path, "wb") as f:
112
  f.write(r.content)
113
  thumbnail_path = thumb_path
114
+ await message.reply_audio(
 
115
  audio=file_path,
116
  thumb=thumbnail_path,
117
  file_name=title,