add transaction for creating tvshow and episodes

This commit is contained in:
2024-11-06 19:29:14 +01:00
parent a4591aa177
commit e541681dd1
8 changed files with 92 additions and 173 deletions
+6
View File
@@ -107,10 +107,14 @@ func ScrapeEpisodes(ttImdb string) (string, []Episode) {
c.Visit(fmt.Sprintf(visitURL, ttImdb))
c.Wait()
slog.Info("scraped all seasons", "seasons", allSeasons)
return title, allSeasons
}
func extractEpisodesFromSeason(data string) []Episode {
slog.Info("extracting episodes", "data", data)
const pattern = `(S\d+\.E\d+)\s∙\s(.*?)` +
`(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s` +
`(.*?),\s(\d{4})(.*?)` +
@@ -121,6 +125,8 @@ func extractEpisodesFromSeason(data string) []Episode {
episodes := make([]Episode, 0, len(matches))
slog.Info("matches", "num", len(matches))
for _, match := range matches {
var episode Episode