Skip to content

Commit

Permalink
Feat: Select which category you want to watch
Browse files Browse the repository at this point in the history
Feat: Anime poster and notification when starting new episode
  • Loading branch information
Wraient committed Oct 28, 2024
1 parent 6414ff6 commit 978227d
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 218 deletions.
5 changes: 5 additions & 0 deletions cmd/curd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func main() {
imagePreview := flag.Bool("image-preview", false, "Show image preview")
noImagePreview := flag.Bool("no-image-preview", false, "No image preview")
changeToken := flag.Bool("change-token", false, "Change token")
currentCategory := flag.Bool("current", false, "Current category")
updateScript := flag.Bool("u", false, "Update the script")
editConfig := flag.Bool("e", false, "Edit config")
subFlag := flag.Bool("sub", false, "Watch sub version")
Expand Down Expand Up @@ -100,6 +101,10 @@ func main() {
return
}

if *currentCategory {
userCurdConfig.CurrentCategory = true
}

if *rofiSelection {
userCurdConfig.RofiSelection = true
}
Expand Down
14 changes: 13 additions & 1 deletion internal/anime_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@ func SearchAnime(query, mode string) (map[string]string, error) {
return animeList, err
}

// Debug: Log the response status and first part of body
Log(fmt.Sprintf("Response Status: %s", resp.Status), logFile)
Log(fmt.Sprintf("Response Body (first 500 chars): %s", string(body[:min(len(body), 500)])), logFile)

// Parse the JSON response
var response response
err = json.Unmarshal(body, &response)
if err != nil {
Log(fmt.Sprint("Error parsing JSON:", err), logFile)
Log(fmt.Sprintf("Error parsing JSON for query '%s': %v\nBody: %s", query, err, string(body)), logFile)
return animeList, err
}

Expand Down Expand Up @@ -119,3 +123,11 @@ func SearchAnime(query, mode string) (map[string]string, error) {
}
return animeList, nil
}

// Helper function
func min(a, b int) int {
if a < b {
return a
}
return b
}
1 change: 1 addition & 0 deletions internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CurdConfig struct {
ImagePreview bool `config:"ImagePreview"`
SkipRecap bool `config:"SkipRecap"`
RofiSelection bool `config:"RofiSelection"`
CurrentCategory bool `config:"CurrentCategory"`
ScoreOnCompletion bool `config:"ScoreOnCompletion"`
SaveMpvSpeed bool `config:"SaveMpvSpeed"`
DiscordPresence bool `config:"DiscordPresence"`
Expand Down
Loading

0 comments on commit 978227d

Please sign in to comment.