Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.52 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.52 KB

go-jellyfin

An API client library for Jellyfin music functionality for Go.

This code is an adaptation of the Jellyfin API implementation from the Jellycli project, originally written by Tero Vierimaa (@tryffel). Also a very helpful resource was the Jellyfin API layer of Sonixd.

The scope of this library is currently music-only, as it is being built for the Supersonic project.

Status

This library is functional, and currently in use in Supersonic. However, it is certainly not API stable and can be expected to change frequently.

Example

import (
    "github.com/dweymouth/go-jellyfin"
    "log"
)

func main() {
    // create client
    jellyClient, err := jellyfin.NewClient("https://jellyfin.example.com", "supersonic", "1")
    if err != nil {
        log.Fatalf("unable to create jellyfin client: %v", err)
    }

    // login. Saves the access key to Client for future calls.
    if err := jellyClient.Login("user", "pass"); err != nil {
        log.Fatalf("unable to log in to jellyfin: %v", err)
    }

    // get albums between 2000-2010
    filter := jellyfin.QueryOpts{
        Filter: jellyfin.Filter{
            YearRange: []int{2000, 2010},
        },
    }

    albums, err := jellyClient.GetAlbums(filter)
    if err != nil {
        log.Fatalf("unable to get albums: %v", err)
    }

    // print out all the album names
    for _, album := range albums {
        log.Print(album.Name)
    }
}