This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from Z-Jais/master
Update and fix bugs
- Loading branch information
Showing
9 changed files
with
78 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package fr.jais.scraper.jobs | ||
|
||
import fr.jais.scraper.Scraper | ||
import fr.jais.scraper.entities.Episode | ||
import fr.jais.scraper.utils.* | ||
import org.quartz.Job | ||
import org.quartz.JobExecutionContext | ||
import java.util.* | ||
|
||
class CheckJob : Job { | ||
override fun execute(p0: JobExecutionContext?) { | ||
getAllEpisodes(Calendar.getInstance()).forEach { println(it) } | ||
} | ||
|
||
private fun getAllEpisodes(calendar: Calendar): List<Episode> { | ||
Logger.config("Calendar: ${calendar.toISO8601()}") | ||
|
||
Logger.info("Getting cached episodes...") | ||
val cachedEpisodes = Database.loadEpisodes().map { it.hash } | ||
|
||
Logger.info("Get all episodes...") | ||
val episodes = Scraper.instance.platforms | ||
.flatMap { it.getEpisodes(calendar, cachedEpisodes) } | ||
.filter { calendar.after(CalendarConverter.fromUTCDate(it.releaseDate)) } | ||
.sortedWith( | ||
compareBy( | ||
{ CalendarConverter.fromUTCDate(it.releaseDate) }, | ||
{ it.anime.name.lowercase() }, | ||
{ it.season }, | ||
{ it.number } | ||
) | ||
) | ||
Logger.config("Episodes: ${episodes.size}") | ||
Database.saveEpisodes(episodes) | ||
API.saveEpisodes(episodes) | ||
return episodes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package fr.jais.scraper.jobs | ||
|
||
import fr.jais.scraper.Scraper | ||
import fr.jais.scraper.utils.Logger | ||
import org.quartz.Job | ||
import org.quartz.JobExecutionContext | ||
|
||
class ClearJob : Job { | ||
override fun execute(p0: JobExecutionContext?) { | ||
Logger.info("Reset all platforms...") | ||
Scraper.instance.platforms.forEach { it.reset() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters