forked from silentmurdock/wrserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
108 lines (85 loc) · 3.83 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"context"
"github.com/nyakaspeter/raven-torrent/internal/httpserver"
"github.com/nyakaspeter/raven-torrent/internal/settings"
"github.com/nyakaspeter/raven-torrent/internal/torrentclient"
torrentclienttypes "github.com/nyakaspeter/raven-torrent/internal/torrentclient/types"
"github.com/nyakaspeter/raven-torrent/pkg/dlnacast"
dlnacasttypes "github.com/nyakaspeter/raven-torrent/pkg/dlnacast/types"
"github.com/nyakaspeter/raven-torrent/pkg/mediainfo"
mediainfotypes "github.com/nyakaspeter/raven-torrent/pkg/mediainfo/types"
"github.com/nyakaspeter/raven-torrent/pkg/mediaplayer"
mediaplayertypes "github.com/nyakaspeter/raven-torrent/pkg/mediaplayer/types"
"github.com/nyakaspeter/raven-torrent/pkg/subtitles"
subtitlestypes "github.com/nyakaspeter/raven-torrent/pkg/subtitles/types"
"github.com/nyakaspeter/raven-torrent/pkg/torrents"
torrentstypes "github.com/nyakaspeter/raven-torrent/pkg/torrents/types"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
settings.Init()
torrentclient.StartTorrentClient()
httpserver.StartHttpServer(nil)
}
func (a *App) DiscoverMovies(params mediainfotypes.MovieDiscoverParams, language string, page int) mediainfotypes.MovieResults {
return mediainfo.DiscoverMovies(params, language, page)
}
func (a *App) DiscoverShows(params mediainfotypes.ShowDiscoverParams, language string, page int) mediainfotypes.ShowResults {
return mediainfo.DiscoverShows(params, language, page)
}
func (a *App) SearchMovies(title string, language string, page int) mediainfotypes.MovieResults {
return mediainfo.SearchMovies(title, language, page)
}
func (a *App) SearchShows(title string, language string, page int) mediainfotypes.ShowResults {
return mediainfo.SearchShows(title, language, page)
}
func (a *App) GetMovieInfo(tmdbId int, language string) mediainfotypes.MovieInfo {
return mediainfo.GetMovieInfo(tmdbId, language)
}
func (a *App) GetShowInfo(tmdbId int, language string) mediainfotypes.ShowInfo {
return mediainfo.GetShowInfo(tmdbId, language)
}
func (a *App) GetShowSeason(tmdbId int, seasonNumber int, language string) mediainfotypes.SeasonInfo {
return mediainfo.GetShowSeason(tmdbId, seasonNumber, language)
}
func (a *App) GetMovieTorrents(movie torrentstypes.MovieParams, sources torrentstypes.SourceParams) []torrentstypes.MovieTorrent {
return torrents.GetMovieTorrents(movie, sources)
}
func (a *App) GetShowTorrents(show torrentstypes.ShowParams, sources torrentstypes.SourceParams) []torrentstypes.ShowTorrent {
return torrents.GetShowTorrents(show, sources)
}
func (a *App) AddTorrent(uri string) torrentclienttypes.TorrentInfo {
return torrentclient.AddTorrent(uri)
}
func (a *App) RemoveTorrent(hash string) error {
return torrentclient.RemoveTorrent(hash)
}
func (a *App) GetActiveTorrents() []torrentclienttypes.TorrentInfo {
return torrentclient.GetActiveTorrents()
}
func (a *App) GetSubtitles(movie subtitlestypes.MediaParams, languages []string) []subtitlestypes.SubtitleFile {
return subtitles.GetSubtitles(movie, languages)
}
func (a *App) GetSubtitlesForEpisode(movie subtitlestypes.MediaParams, episode subtitlestypes.EpisodeParams, languages []string) []subtitlestypes.SubtitleFile {
return subtitles.GetSubtitlesForEpisode(movie, episode, languages)
}
func (a *App) GetMediaDevices() []dlnacasttypes.MediaDevice {
return dlnacast.GetMediaDevices()
}
func (a *App) CastMediaToDevice(media dlnacasttypes.MediaParams, deviceLocation string) error {
return dlnacast.CastMediaToDevice(media, deviceLocation)
}
func (a *App) StartMediaPlayer(params mediaplayertypes.MediaPlayerParams) error {
return mediaplayer.StartMediaPlayer(params)
}