Skip to content

Commit 9158502

Browse files
committed
add configVar 'ytdlFormat' and refactor
1 parent 6ee9cc4 commit 9158502

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

deploy/setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def fileUpload(fileName: str) -> str:
138138
'max-connection-per-server': '8', 'max-overall-upload-limit': '1K',
139139
'min-split-size': '10M', 'seed-time': '0.01', 'split': '10'},
140140
'authorizedChats': {}, 'dlRootDir': 'dl', 'logLevel': 'INFO', 'megaAuth': {'apiKey': '', 'emailId': '', 'passPhrase': ''},
141-
'statusUpdateInterval': '5', 'trackersListUrl': 'https://trackerslist.com/all_aria2.txt'}
141+
'statusUpdateInterval': '5', 'trackersListUrl': 'https://trackerslist.com/all_aria2.txt',
142+
'ytdlFormat': 'best/bestvideo+bestaudio'}
142143
envVars: typing.Dict = {'dlWaitTime': '5'}
143144

144145
if __name__ == '__main__':

tgmb/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ def initHelper(self) -> None:
210210
self.reqVars: [str] = ['botToken', 'botOwnerId', 'telegramApiId', 'telegramApiHash',
211211
'googleDriveAuth', 'googleDriveUploadFolderIds']
212212
self.optVars: typing.List[str] = ['ariaGlobalOpts', 'authorizedChats', 'dlRootDir', 'logLevel',
213-
'megaAuth', 'statusUpdateInterval', 'trackersListUrl']
213+
'megaAuth', 'statusUpdateInterval', 'trackersListUrl', 'ytdlFormat']
214214
self.optVals: typing.List[typing.Union[str, typing.Dict]] = \
215215
[{'allow-overwrite': 'true', 'bt-max-peers': '0', 'follow-torrent': 'mem',
216216
'max-connection-per-server': '8', 'max-overall-upload-limit': '1K',
217217
'min-split-size': '10M', 'seed-time': '0.01', 'split': '10'},
218-
{}, 'dl', 'INFO', {}, '5', 'https://trackerslist.com/all_aria2.txt']
218+
{}, 'dl', 'INFO', {}, '5', 'https://trackerslist.com/all_aria2.txt', 'best/bestvideo+bestaudio']
219219
self.emptyVals: typing.List[typing.Union[str, typing.Dict]] = ['', ' ', {}]
220220
self.isFixConfigJson: bool = False
221221
self.configVarsLoad()
@@ -1659,7 +1659,7 @@ def initHelper(self) -> None:
16591659
super().initHelper()
16601660

16611661
def addDownload(self, mirrorInfo: 'MirrorInfo') -> None:
1662-
ytdlOpts: dict = {'quiet': True, 'format': 'best/bestvideo+bestaudio', 'progress_hooks': [self.progressHook],
1662+
ytdlOpts: dict = {'quiet': True, 'format': mirrorInfo.ytdlFormat, 'progress_hooks': [self.progressHook],
16631663
'outtmpl': f'{mirrorInfo.path}/%(title)s-%(id)s.f%(format_id)s.%(ext)s'}
16641664
self.downloadVideo(mirrorInfo.downloadUrl, ytdlOpts)
16651665

@@ -2201,6 +2201,7 @@ def __init__(self, msg: telegram.Message, botHelper: BotHelper):
22012201
self.status: str = ''
22022202
self.tag: str = ''
22032203
self.downloadUrl: str = ''
2204+
self.ytdlFormat: str = botHelper.configHelper.configVars[botHelper.configHelper.optVars[7]]
22042205
self.sizeTotal: int = 0
22052206
self.sizeCurrent: int = 0
22062207
self.timeStart: float = 0.0

0 commit comments

Comments
 (0)