fix download task only using 1st apikey
This commit is contained in:
parent
849a03fe34
commit
cd453f85a4
17 changed files with 18 additions and 0 deletions
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
0
aboutCommand.py
Executable file → Normal file
0
aboutCommand.py
Executable file → Normal file
0
bot.py
Executable file → Normal file
0
bot.py
Executable file → Normal file
1
checkVideo.py
Executable file → Normal file
1
checkVideo.py
Executable file → Normal file
|
|
@ -18,6 +18,7 @@ async def checkVideo(results):
|
|||
print("loading " + str(video.url))
|
||||
if (video.status == 403): # check if the status code is 403 (access denies)
|
||||
print("switched to next APIkey")
|
||||
await session.close()
|
||||
apikeyID = apikeyID + 1 # if yes use the next apiKey
|
||||
# if the current APIkey is the last one in the array, use the first one
|
||||
if (apikeyID >= len(apikey)):
|
||||
|
|
|
|||
0
checkVideos.py
Executable file → Normal file
0
checkVideos.py
Executable file → Normal file
0
config_example.py
Executable file → Normal file
0
config_example.py
Executable file → Normal file
0
databaseStructure.sql
Executable file → Normal file
0
databaseStructure.sql
Executable file → Normal file
17
download.py
Executable file → Normal file
17
download.py
Executable file → Normal file
|
|
@ -3,12 +3,28 @@ from requests import get as getNonAsync
|
|||
|
||||
def download(url, serverID):
|
||||
global nextTitle
|
||||
global apikeyID
|
||||
|
||||
print("loading playlist " + url)
|
||||
playlist = url.split("list=")[1]
|
||||
r = getNonAsync("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=" + playlist + "&key=" + apikey[apikeyID])
|
||||
|
||||
startKeyID = apikeyID
|
||||
while(r.status_code == 403):
|
||||
apikeyID+=1
|
||||
print("switching download to next api key. new id is " + str(apikeyID))
|
||||
if (apikeyID >= len(apikey)):
|
||||
apikeyID = 0
|
||||
if (startKeyID == apikeyID):
|
||||
print("used up all API keys for YouTube, please add more")
|
||||
return # we can stop here, the bot will hang here
|
||||
|
||||
r = getNonAsync("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=" + playlist + "&key=" + apikey[apikeyID])
|
||||
|
||||
if(r.status_code != 200):
|
||||
print("recived status code " + str(r.status_code) + " aborting. Used API key ID was " +str(apikeyID))
|
||||
return
|
||||
|
||||
playlistData = loads(r.text)
|
||||
|
||||
videosInPlaylist = []
|
||||
|
|
@ -18,6 +34,7 @@ def download(url, serverID):
|
|||
|
||||
videoID = choice(videosInPlaylist)
|
||||
videoURL = "https://youtu.be/" + videoID
|
||||
print("downloading " + videoURL)
|
||||
|
||||
|
||||
ydl_opts = { # youtube-dl arguments
|
||||
|
|
|
|||
0
dummyPlayer.py
Executable file → Normal file
0
dummyPlayer.py
Executable file → Normal file
0
generalCommands.py
Executable file → Normal file
0
generalCommands.py
Executable file → Normal file
0
heartBeatTask.py
Executable file → Normal file
0
heartBeatTask.py
Executable file → Normal file
0
monitorCommands.py
Executable file → Normal file
0
monitorCommands.py
Executable file → Normal file
0
permissionCheck.py
Executable file → Normal file
0
permissionCheck.py
Executable file → Normal file
0
radioCommands.py
Executable file → Normal file
0
radioCommands.py
Executable file → Normal file
0
radioTask.py
Executable file → Normal file
0
radioTask.py
Executable file → Normal file
0
requirements.txt
Executable file → Normal file
0
requirements.txt
Executable file → Normal file
0
setup.py
Executable file → Normal file
0
setup.py
Executable file → Normal file
Loading…
Add table
Add a link
Reference in a new issue