music: attempt to fix random errors with sc playlists
This commit is contained in:
		
							parent
							
								
									4bcb64d104
								
							
						
					
					
						commit
						b3444b16e1
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		| 
						 | 
					@ -84,9 +84,16 @@ async function processPlaylist(
 | 
				
			||||||
    const clientId = await getSoundcloudClientID();
 | 
					    const clientId = await getSoundcloudClientID();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (url.indexOf("/likes") > -1) {
 | 
					    if (url.indexOf("/likes") > -1) {
 | 
				
			||||||
      const userInfo = await fetch(
 | 
					      let userInfo = await fetch(
 | 
				
			||||||
        `https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
 | 
					        `https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
 | 
				
			||||||
      ).then((res) => res.json());
 | 
					      ).then((res) => res.json());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      while (!userInfo.uri) {
 | 
				
			||||||
 | 
					        userInfo = await fetch(
 | 
				
			||||||
 | 
					          `https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
 | 
				
			||||||
 | 
					        ).then((res) => res.json());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const likesUrl =
 | 
					      const likesUrl =
 | 
				
			||||||
        userInfo.uri.replace("api.", "api-v2.") +
 | 
					        userInfo.uri.replace("api.", "api-v2.") +
 | 
				
			||||||
        "/likes?limit=500&client_id=" +
 | 
					        "/likes?limit=500&client_id=" +
 | 
				
			||||||
| 
						 | 
					@ -171,6 +178,8 @@ async function enqueue(
 | 
				
			||||||
  addedBy,
 | 
					  addedBy,
 | 
				
			||||||
  suppress = false
 | 
					  suppress = false
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
 | 
					  if (!url) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const connection =
 | 
					  const connection =
 | 
				
			||||||
    voiceStorage.get(guild_id) ??
 | 
					    voiceStorage.get(guild_id) ??
 | 
				
			||||||
    (await createVoiceConnection(guild_id, voice_id, text_id));
 | 
					    (await createVoiceConnection(guild_id, voice_id, text_id));
 | 
				
			||||||
| 
						 | 
					@ -205,6 +214,7 @@ async function enqueue(
 | 
				
			||||||
      highWaterMark: 1 << 25,
 | 
					      highWaterMark: 1 << 25,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  } else if (type == "sc") {
 | 
					  } else if (type == "sc") {
 | 
				
			||||||
 | 
					    if (url.startsWith("sc:"))
 | 
				
			||||||
      url = url.replace(/^sc:/, "https://soundcloud.com/");
 | 
					      url = url.replace(/^sc:/, "https://soundcloud.com/");
 | 
				
			||||||
    const client_id = await getSoundcloudClientID();
 | 
					    const client_id = await getSoundcloudClientID();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue