Documentation
¶
Index ¶
- Constants
- Variables
- func InitDevice(logger *slog.Logger, mountpoint string, device string, serial string, ...) error
- func IsDeviceInitialised(mountpoint string) (bool, error)
- func ModifyTrack(logger *slog.Logger, t *C.Itdb_Track, mods ...TrackModifier)
- type GPod
- func (g *GPod) Cleanup(logger *slog.Logger, orphaned bool, invalid func(comment string) error) error
- func (g *GPod) Close()
- func (g *GPod) ResetRecentPlaycount(comment string)
- func (g *GPod) Save() error
- func (g *GPod) SortAlbums(how SortMethod)
- func (g *GPod) SyncTracks(ctx context.Context, logger *slog.Logger, want []Track, ...) error
- func (g *GPod) TrackByComment(comment string) *C.Itdb_Track
- func (g *GPod) Tracks() iter.Seq[Track]
- type MarkUnplayed
- type MediaType
- type PlaylistMeta
- type SortMethod
- type Track
- type TrackModifier
- type Writer
- type WriterTo
Constants ¶
const ( MarkUnplayed_Unplayed = MarkUnplayed(0x2) MarkUnplayed_Played = MarkUnplayed(0x1) )
const ( MT_Audio = MediaType(C.ITDB_MEDIATYPE_AUDIO) MT_Movie = MediaType(C.ITDB_MEDIATYPE_MOVIE) MT_Podcast = MediaType(C.ITDB_MEDIATYPE_PODCAST) MT_Audiobook = MediaType(C.ITDB_MEDIATYPE_AUDIOBOOK) MT_MusicVideo = MediaType(C.ITDB_MEDIATYPE_MUSICVIDEO) MT_TVShow = MediaType(C.ITDB_MEDIATYPE_TVSHOW) MT_Ringtone = MediaType(C.ITDB_MEDIATYPE_RINGTONE) MT_Rental = MediaType(C.ITDB_MEDIATYPE_RENTAL) MT_ItunesExtra = MediaType(C.ITDB_MEDIATYPE_ITUNES_EXTRA) MT_Memo = MediaType(C.ITDB_MEDIATYPE_MEMO) MT_EPUBBook = MediaType(C.ITDB_MEDIATYPE_EPUB_BOOK) MT_PDFBook = MediaType(C.ITDB_MEDIATYPE_PDF_BOOK) )
Variables ¶
var SerialToModel = map[string]string{}/* 243 elements not displayed */
SerialToModel is straight off libgpod. They don't (i think?) expose this through the API. I've also added an M in front of the model number, which seems needed. I've added some serials I've encountered myself but were missing.
Functions ¶
func InitDevice ¶ added in v0.4.0
func InitDevice( logger *slog.Logger, mountpoint string, device string, serial string, force bool, ) error
InitDevice initialises an iPod.
func IsDeviceInitialised ¶ added in v0.4.0
func ModifyTrack ¶ added in v0.3.0
func ModifyTrack(logger *slog.Logger, t *C.Itdb_Track, mods ...TrackModifier)
ModifyTrack changes values in t using mods. This is just to get around the fact that since the struct fields start with a lowercase letter they're not visible outside package. Nice one.
Types ¶
type GPod ¶
type GPod struct {
// contains filtered or unexported fields
}
func (*GPod) Cleanup ¶ added in v0.3.0
func (g *GPod) Cleanup( logger *slog.Logger, orphaned bool, invalid func(comment string) error, ) error
Cleanup cleans up the iPod. The orphaned option removes tracks from the database that don't have a file, or that have a file that's zero bytes in size. The invalid function, if not nil, will be called to check if a track is invalid to your application.
func (*GPod) Close ¶ added in v0.8.0
func (g *GPod) Close()
Close the database without saving it. This frees the memory taken by OpenMount, so it must be called even if the database is saved.
func (*GPod) ResetRecentPlaycount ¶ added in v0.3.0
ResetPlaycount resets the recent playcount of a track by comment.
func (*GPod) SortAlbums ¶ added in v0.5.0
func (g *GPod) SortAlbums(how SortMethod)
SortAlbums sorts the albums according to SortMethod.
func (*GPod) SyncTracks ¶
func (g *GPod) SyncTracks( ctx context.Context, logger *slog.Logger, want []Track, validateComment func(comment string) error, ) error
SyncTracks makes sure the iPod has all the wanted tracks in it. It uses Track.Comment as an unique key, so make sure that's unique. The optional function validateComment is to ignore tracks not managed by your application.
func (*GPod) TrackByComment ¶ added in v0.3.0
func (g *GPod) TrackByComment(comment string) *C.Itdb_Track
type MarkUnplayed ¶
type MarkUnplayed int
func (MarkUnplayed) String ¶ added in v0.3.0
func (m MarkUnplayed) String() string
type PlaylistMeta ¶
type SortMethod ¶ added in v0.5.0
type SortMethod uint8
const ( SortMethod_Alphabetically SortMethod = iota SortMethod_RecentlyAddedFirst )
type Track ¶
type Track struct {
WriteFile Writer `json:"-"`
WriteArtwork WriterTo `json:"-"`
Filename string `json:"filename"`
// Song metadata.
Artist string `json:"artist"`
Album string `json:"album"`
AlbumArtist string `json:"album_artist"`
Title string `json:"title"`
Genere string `json:"genere"`
Composer string `json:"composer"`
Year int `json:"year"`
Comment string `json:"comment"`
TrackLen time.Duration `json:"track_len_ms"`
CDNumber int `json:"cd_number"`
NumberOfCDs int `json:"number_of_cds"`
TrackNumber int `json:"track_number"`
NumberOfTracks int `json:"number_of_tracks"`
BPM int `json:"bpm"`
Compilation int `json:"compilation"`
// For adults=1.
ExplicitFlag int `json:"explicit_flag"`
// Podcast Specific
PodcastURL string `json:"podcast_url"`
PodcastRSS string `json:"podcast_rss"`
// From libgpod:
// Used for podcasts, 0x00 otherwise. If set to
// 0x01 the "Now Playing" page will show
// Title/Album, when set to 0x00 it will also show
// the Artist. When set to 0x02 a sub-page
// (middle button) with further information about
// the track will be shown.
Flag4 int `json:"flag_4"`
TimeReleased time.Time `json:"time_released"`
MarkUnplayed MarkUnplayed `json:"mark_unplayed"`
RememberPlaybackPosition bool `json:"remember_playback_position"`
// TV Show Specific
TVShow string `json:"tv_show"`
TVEpisode string `json:"tv_episode"`
TVNetwork string `json:"tv_network"`
SeasonNumber int `json:"season_number"`
EpisodeNumber int `json:"episode_number"`
// Movie stuff
MovieFlag bool `json:"movie_flag"` // True if movie.
Filetype string `json:"filetype"`
Size int `json:"size"` // In bytes
BitRate int `json:"bit_rate"`
SampleRate int `json:"sample_rate"`
// Number of samples in track.
SampleCount int `json:"sample_count"`
// Start offset for gapless playback, ms.
StartTime time.Duration `json:"start_time"`
// End offset for gapless playback, ms.
StopTime time.Duration `json:"stop_time"`
MediaType MediaType `json:"media_type"`
// Unique ID in the iPod DB.
DBID uint64 `json:"dbid"`
TimeAdded time.Time `json:"time_added"`
TimeModified time.Time `json:"time_modified"`
TimePlayed time.Time `json:"time_played"`
BookmarkTime time.Time `json:"bookmark_time"`
// TODO, there's a formula for this.
Rating int `json:"rating"`
Playcount int `json:"playcount"`
// Times played since last sync.
RecentPlaycount int `json:"recent_playcount"`
// File transferred to ipod?
Transferred bool `json:"transferred"`
AppRating int `json:"app_rating"`
// CBR MP3s and AAC are 0x00, VBR MP3s are 0x01
Type1 int `json:"type_1"`
// MP3s are 0x01, AAC are 0x00
Type2 int `json:"type_2"`
Checked int `json:"checked"`
Visible int `json:"visible"`
ArtworkCount int `json:"artwork_count"`
ArtworkSize int `json:"artwork_size"`
HasArtwork int `json:"has_artwork"`
// Volume stuff. TODO
SoundCheck int `json:"sound_check"`
// Used to sort albums in menus.
SortAlbum *string
Playlists []PlaylistMeta `json:"playlists"`
}
type TrackModifier ¶ added in v0.3.0
type TrackModifier func(t *C.Itdb_Track) string
func TrackModifier_MPL ¶ added in v0.3.0
func TrackModifier_MPL(want bool) TrackModifier
func TrackModifier_SetMediaType ¶ added in v0.3.0
func TrackModifier_SetMediaType(mt MediaType) TrackModifier