Captain Ezio commited on
Commit
d374e7b
·
1 Parent(s): c46aba9
Files changed (1) hide show
  1. Powers/utils/web_helpers.py +16 -2
Powers/utils/web_helpers.py CHANGED
@@ -12,7 +12,10 @@ from youtubesearchpython.__future__ import Video, VideosSearch
12
 
13
  from Powers.bot_class import LOGGER, MESSAGE_DUMP, Gojo
14
  from Powers.utils.http_helper import *
 
 
15
 
 
16
 
17
  async def get_file_size(file: Message):
18
  if file.photo:
@@ -84,10 +87,14 @@ async def song_search(query, is_direct, max_results=1):
84
  "channel": i["channel"]["link"],
85
  "duration": i["accessibility"]['duration'],
86
  "DURATION": i["duration"],
87
- "thumbnail": i["richThumbnail"]["url"],
88
  "published": i["publishedTime"],
89
  "uploader": i ["channel"]["name"]
90
  }
 
 
 
 
 
91
  yt_dict.update({nums: dict_form})
92
  nums += 1
93
  else:
@@ -165,16 +172,23 @@ async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str
165
  thumb = dicti["thumbnail"]
166
  vid_dur = get_duration_in_sec(dicti["DURATION"])
167
  published_on = dicti["published"]
168
- thumb_ = await c.send_photo(MESSAGE_DUMP,thumb)
 
 
 
169
  # FILE = ydl.extract_info(query,download=video)
170
  url = query
171
  thumb = await thumb_.download()
 
 
172
  await thumb_.delete()
173
  cap = f"""
174
  ⤷ Name: `{f_name}`
175
  ⤷ Duration: `{dura}`
176
  ⤷ Views: `{views}`
177
  ⤷ Published: `{published_on}`
 
 
178
  """
179
  kb = IKM(
180
  [
 
12
 
13
  from Powers.bot_class import LOGGER, MESSAGE_DUMP, Gojo
14
  from Powers.utils.http_helper import *
15
+ from Powers.utils.sticker_help import resize_file_to_sticker_size
16
+ from Powers.vars import Config
17
 
18
+ backUP = "https://artfiles.alphacoders.com/160/160160.jpeg"
19
 
20
  async def get_file_size(file: Message):
21
  if file.photo:
 
87
  "channel": i["channel"]["link"],
88
  "duration": i["accessibility"]['duration'],
89
  "DURATION": i["duration"],
 
90
  "published": i["publishedTime"],
91
  "uploader": i ["channel"]["name"]
92
  }
93
+ try:
94
+ thumb = {"thumbnail": i["richThumbnail"]["url"]}
95
+ except Exception:
96
+ thumb = {"thumbnail": None}
97
+ dict_form.update(thumb)
98
  yt_dict.update({nums: dict_form})
99
  nums += 1
100
  else:
 
172
  thumb = dicti["thumbnail"]
173
  vid_dur = get_duration_in_sec(dicti["DURATION"])
174
  published_on = dicti["published"]
175
+ if thumb:
176
+ thumb_ = await c.send_photo(MESSAGE_DUMP,thumb)
177
+ else:
178
+ thumb_ = await c.send_photo(MESSAGE_DUMP,backUP)
179
  # FILE = ydl.extract_info(query,download=video)
180
  url = query
181
  thumb = await thumb_.download()
182
+ if not thumb:
183
+ thumb = await resize_file_to_sticker_size(thumb,320,320)
184
  await thumb_.delete()
185
  cap = f"""
186
  ⤷ Name: `{f_name}`
187
  ⤷ Duration: `{dura}`
188
  ⤷ Views: `{views}`
189
  ⤷ Published: `{published_on}`
190
+
191
+ Downloaded by: @{Config.BOT_USERNAME}
192
  """
193
  kb = IKM(
194
  [