-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
75 lines (64 loc) · 1.66 KB
/
main.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
package main
import (
"context"
"time"
"github.com/deflix-tv/go-stremio"
)
var (
version = "0.1.0"
manifest = stremio.Manifest{
ID: "com.example.blender-catalog",
Name: "Blender movie catalog",
Description: "Catalog addon for free movies that were made with Blender",
Version: version,
ResourceItems: []stremio.ResourceItem{
{
Name: "catalog",
},
},
Types: []string{"movie"},
Catalogs: catalogs,
}
catalogs = []stremio.CatalogItem{
{
Type: "movie",
ID: "blender",
Name: "Free movies made with Blender",
},
}
)
func main() {
// Let the movieHandler handle the "movie" type
catalogHandlers := map[string]stremio.CatalogHandler{"movie": movieHandler}
// We want clients and proxies to cache the response for 24 hours
// and upon request with the same hash we only return a 304 Not Modified.
options := stremio.Options{
CacheAgeCatalogs: 24 * time.Hour,
CachePublicCatalogs: true,
HandleEtagCatalogs: true,
}
addon, err := stremio.NewAddon(manifest, catalogHandlers, nil, options)
if err != nil {
panic(err)
}
addon.Run(nil)
}
func movieHandler(ctx context.Context, id string, userData interface{}) ([]stremio.MetaPreviewItem, error) {
if id != "blender" {
return nil, stremio.NotFound
}
return []stremio.MetaPreviewItem{
{
ID: "tt1254207",
Type: "movie",
Name: "Big Buck Bunny",
Poster: "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Big_buck_bunny_poster_big.jpg/339px-Big_buck_bunny_poster_big.jpg",
},
{
ID: "tt1727587",
Type: "movie",
Name: "Sintel",
Poster: "https://images.metahub.space/poster/small/tt1727587/img",
},
}, nil
}