Skip to content

Commit

Permalink
library: list unscraped media
Browse files Browse the repository at this point in the history
  • Loading branch information
sj14 committed Apr 29, 2024
1 parent ebb34e6 commit 86c3a02
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
38 changes: 37 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
},
{
Name: "system",
Usage: "Manage system",
Usage: "Manage the system",
Subcommands: []*cli.Command{
{
Name: "shutdown",
Expand Down Expand Up @@ -171,6 +171,42 @@ func main() {
})
},
},
{
Name: "unscraped",
Usage: "List entries which were not scraped",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "movies",
Value: true,
Usage: "show unscraped movies",
},
&cli.BoolFlag{
Name: "shows",
Value: true,
Usage: "show unscraped shows",
},
&cli.BoolFlag{
Name: "seasons",
Value: false,
Usage: "show unscraped seasons",
},
&cli.BoolFlag{
Name: "episodes",
Value: false,
Usage: "show unscraped episodes",
},
},
Action: func(ctx *cli.Context) error {
return Exec(ctx, func(ctrl *pkg.Controller) (*http.Response, error) {
return ctrl.LibraryUnscraped(
ctx.Bool("movies"),
ctx.Bool("shows"),
ctx.Bool("seasons"),
ctx.Bool("episodes"),
)
})
},
},
},
},
},
Expand Down
38 changes: 38 additions & 0 deletions pkg/library.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
package pkg

import (
"fmt"
"net/http"

"github.com/sj14/jellyfin-go/api"
)

func (c *Controller) LibraryScan() (*http.Response, error) {
return c.client.LibraryAPI.RefreshLibrary(c.ctx).Execute()
}

func (c *Controller) LibraryUnscraped(movies, series, season, episode bool) (*http.Response, error) {
// Determine based on missing production date
// TODO: look for a better endpoints/approach.

var types []api.BaseItemKind
if movies {
types = append(types, api.BASEITEMKIND_MOVIE)
}
if series {
types = append(types, api.BASEITEMKIND_SERIES)
}
if season {
types = append(types, api.BASEITEMKIND_SEASON)
}
if episode {
types = append(types, api.BASEITEMKIND_EPISODE)
}

result, resp, err := c.client.ItemsAPI.GetItems(c.ctx).
Recursive(true).
IncludeItemTypes(types).
Filters([]api.ItemFilter{api.ITEMFILTER_IS_NOT_FOLDER}).
Execute()
if err != nil {
return resp, err
}

for _, item := range result.Items {
if !item.ProductionYear.IsSet() {
fmt.Printf("(%s) %s\n", item.GetType(), item.GetName())
}
}
return resp, err
}

0 comments on commit 86c3a02

Please sign in to comment.