Esempio n. 1
0
//haveNotWatchedIt returns true if this episode hase not yet been downloaded
func haveNotWatchedIt(title, dbFilePath string) bool {
	db := database.GetDB(dbFilePath)
	defer db.Close()

	title = strings.ToLower(title)
	properFormat, _ := regexp.MatchString(`(.*)(s[0-9]*e[0-9]*).*`, title)

	if !properFormat {
		return false
	}

	showName, se := ExtarctShow(title)
	currentSeason, currentEpisode := ExtractSeasonEpisode(se)

	lastSE := database.GetValue(db, []byte(strings.ToLower(showName)))
	if lastSE == nil {

		return true
	}

	lastSeason, lastEpisode := ExtractSeasonEpisode(string(lastSE))

	if lastSeason < currentSeason {
		return true
	} else if lastEpisode < currentEpisode {
		return true
	}

	return false
}
Esempio n. 2
0
//addToDB adds a key-value pair title-last season and last episode to DB
func addToDB(itemTitle, dbFilePath string) {
	db := database.GetDB(dbFilePath)
	defer db.Close()

	titleToLowerCase := strings.ToLower(itemTitle)

	showName, se := ExtarctShow(titleToLowerCase)
	database.StoreData(db, []byte(showName), []byte(se))
}