Skip to content

Commit

Permalink
Add some delay before download to try to fix no audio vod?
Browse files Browse the repository at this point in the history
  • Loading branch information
HitomaruKonpaku committed Nov 29, 2024
1 parent 2b97fa7 commit e8b2542
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/modules/TwitCastingCrawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,24 @@ export class TwitCastingCrawler extends EventEmitter {
this.checkUserWithTimeout(user)
return
}

if (movie.live && !this.videoIds.has(movie.id)) {
this.videoIds.add(movie.id)
await this.getMoveMetadata(user, movie)

const movieUrl = TwitCastingUtil.getMovieUrl(user.id, movie.id)
this.logger.warn(`${user.id} live: ${movieUrl}`)
this.sendWebhooks(user, movie)
const output = path.join(configManager.getOutDir(), 'twitcasting', `[%(uploader_id)s][${Util.getTimeString()}] %(title)s (%(id)s).%(ext)s`)

const output = path.join(
configManager.getOutDir(),
'twitcasting',
`[%(uploader_id)s][${Util.getTimeString()}] %(title)s (%(id)s).%(ext)s`,
)

const sleepMs = Number(process.env.TWITCASTING_DOWNLOAD_DELAY) || 0
await Util.sleep(sleepMs)

Downloader.downloadUrl(movieUrl, {
output,
// Add formatSort due to yt-dlp error
Expand Down
6 changes: 6 additions & 0 deletions src/utils/Util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export class Util {
public static sleep(ms?: number) {
return new Promise((resolve) => {
setTimeout(() => resolve(null), ms)
})
}

public static getTimeString(ms?: number): string {
const date = ms
? new Date(ms)
Expand Down

0 comments on commit e8b2542

Please sign in to comment.