-
Notifications
You must be signed in to change notification settings - Fork 8
/
emby.ts
74 lines (69 loc) · 3.7 KB
/
emby.ts
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
import { getPlaybackInfo } from "./play";
import { getActor, getCollection, getEpisodes, getItem, getLatestMedia, getMedia, getRecommendations, getResume, getSeasons, getView, lookupItem, markFavorite, searchRecommend, startPlay, stopPlay, trackPlay } from "./view";
import { getPublicInfo } from "./info";
import { login } from "./login";
import { EmbySite } from "@model/EmbySite";
import { getItemImage, imageUrl, playUrl } from "./config";
export class Emby {
private _site?: EmbySite;
get site() {
if (!this._site) throw Error("site can't be null")
return this._site;
}
set site(site: EmbySite) {
this._site = site
this.bind()
}
constructor(site?: EmbySite) {
this._site = site
this.bind()
}
bind() {
this.getMedia = getMedia.bind(this, this.site)
this.getPlaybackInfo = getPlaybackInfo?.bind(this, this.site)
this.getView = getView.bind(this, this.site)
this.getLatestMedia = getLatestMedia.bind(this, this.site)
this.getCollection = getCollection.bind(this, this.site)
this.getResume = getResume.bind(this, this.site)
this.getRecommendations = getRecommendations.bind(this, this.site)
this.getEpisodes = getEpisodes.bind(this, this.site)
this.getSeasons = getSeasons.bind(this, this.site)
this.getItemWithName = lookupItem.bind(this, this.site)
this.searchRecommend = searchRecommend.bind(this, this.site)
this.getPublicInfo = getPublicInfo.bind(this, this.site)
this.getItem = getItem.bind(this, this.site)
this.getActor = getActor.bind(this, this.site)
this.getItemImage = getItemImage.bind(this, this.site)
this.imageUrl = imageUrl.bind(this, this.site)
this.videoUrl = playUrl.bind(this, this.site)
this.markFavorite = markFavorite.bind(this, this.site)
this.startPlay = startPlay.bind(this, this.site)
this.stopPlay = stopPlay.bind(this, this.site)
this.trackPlay = trackPlay.bind(this, this.site)
}
public getPlaybackInfo = this._site ? getPlaybackInfo.bind(this, this.site) : null
public getMedia = this._site ? getMedia.bind(this, this.site) : null
public getView = this._site ? getView.bind(this, this.site) : null
public getLatestMedia = this._site ? getLatestMedia.bind(this, this.site) : null
public getPublicInfo = this._site ? getPublicInfo.bind(this, this.site) : null
public getCollection = this._site ? getCollection.bind(this, this.site) : null
public getResume = this._site ? getResume.bind(this, this.site) : null
public getRecommendations = this._site ? getRecommendations.bind(this, this.site) : null
public getEpisodes = this._site ? getEpisodes.bind(this, this.site) : null
public getSeasons = this._site ? getSeasons.bind(this, this.site) : null
public getItemWithName = this._site ? lookupItem.bind(this, this.site) : null
public searchRecommend = this._site ? searchRecommend.bind(this, this.site) : null
public getItem = this._site ? getItem.bind(this, this.site) : null
public getActor = this._site ? getActor.bind(this, this.site) : null
public getItemImage = this._site ? getItemImage.bind(this, this.site) : null
public imageUrl = this._site ? imageUrl.bind(this, this.site) : null
public videoUrl = this._site ? playUrl.bind(this, this.site) : null
public markFavorite = this._site ? markFavorite.bind(this, this.site) : null
public startPlay = this._site ? startPlay.bind(this, this.site) : null
public stopPlay = this._site ? stopPlay.bind(this, this.site) : null
public trackPlay = this._site ? trackPlay.bind(this, this.site) : null
}
export const Api = {
emby: null as Emby|null,
login: login
};