Skip to content

Commit a6dab86

Browse files
Fixed an exception in ytdl module
Fixed #230 Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
1 parent d699e3f commit a6dab86

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def __init__(self, listener):
5252
self.vid_id = ''
5353
self.__resource_lock = threading.RLock()
5454

55+
@property
56+
def name(self):
57+
with self.__resource_lock:
58+
return self.__name
59+
5560
@property
5661
def download_speed(self):
5762
with self.__resource_lock:
@@ -116,14 +121,14 @@ def extractMetaData(self, link, qual):
116121
if v.get('filesize'):
117122
self.size += float(v['filesize'])
118123
# For playlists, ydl.prepare-filename returns the following format: <Playlist Name>-<Id of playlist>.NA
119-
self.name = name.split(f"-{result['id']}")[0]
124+
self.__name = name.split(f"-{result['id']}")[0]
120125
self.vid_id = video.get('id')
121126
self.is_playlist = True
122127
else:
123128
video = result
124129
if video.get('filesize'):
125130
self.size = float(video.get('filesize'))
126-
self.name = name
131+
self.__name = name
127132
self.vid_id = video.get('id')
128133
return video
129134

bot/helper/mirror_utils/status_utils/youtube_dl_download_status.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from bot import DOWNLOAD_DIR
22
from bot.helper.ext_utils.bot_utils import MirrorStatus, get_readable_file_size, get_readable_time
33
from .status import Status
4-
4+
import typing
5+
if typing.TYPE_CHECKING:
6+
from bot.helper.mirror_utils.download_utils.youtube_dl_download_helper import YoutubeDLHelper
57

68
class YoutubeDLDownloadStatus(Status):
7-
def __init__(self, obj, listener):
8-
self.obj = obj
9+
def __init__(self, obj: "YoutubeDLHelper", listener):
10+
self.obj: "YoutubeDLHelper" = obj
911
self.uid = listener.uid
1012
self.message = listener.message
1113

0 commit comments

Comments
 (0)