Skip to content

Commit

Permalink
Randomize first proxy selection (#2231)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism authored Sep 25, 2024
1 parent eb31663 commit ca844d2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/helpers/kmq_song_downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class KmqSongDownloader {
.filter((x) => x);

logger.info(
`Found ${this.proxies} proxies. proxies = ${JSON.stringify(this.proxies)}`,
`Found ${this.proxies.length} proxies. proxies = ${JSON.stringify(this.proxies)}`,
);
}
}
Expand Down Expand Up @@ -191,12 +191,12 @@ export default class KmqSongDownloader {

// update current list of non-downloaded songs
await this.updateNotDownloaded(db, allSongs);

const proxySeed = Date.now();
for (let i = 0; i < songsToDownload.length; i++) {
const song = songsToDownload[i]!;
let proxy: string | undefined;
if (KmqConfiguration.Instance.ytdlpDownloadWithProxy()) {
proxy = this.proxies[i % this.proxies.length];
proxy = this.proxies[(i + proxySeed) % this.proxies.length];
logger.info(
`Downloading song: '${song.songName}' by ${song.artistName} | ${
song.youtubeLink
Expand Down

0 comments on commit ca844d2

Please sign in to comment.