adapters

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL           = "https://www.youtube.com/"
	FeedURLBase       = BaseURL + "feeds/videos.xml"
	HTTPClientTimeout = time.Second * 5
)
View Source
const (
	YouTubeChannelsMaxResults = 3
	YouTubeChannelBaseURL     = "https://www.youtube.com/channel/"
)

Variables

View Source
var FeedURL *url.URL

Functions

func NewYouTube

func NewYouTube() (*youtube.Service, error)

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache keeps firestore client and collection

func NewCacheRepository

func NewCacheRepository() (Cache, error)

NewCacheRepository establishes connection to Firebase and update singleton variable

func (*Cache) GetKey

func (c *Cache) GetKey(ctx context.Context, key string) (string, error)

GetKey retrieve value by key from cache store

func (*Cache) SetKey

func (c *Cache) SetKey(ctx context.Context, key, value string, exp time.Duration) error

SetKey saves value for key in cache store with expiration time

type CacheEntity

type CacheEntity struct {
	Key   string        `firestore:"key"`
	Value string        `firestore:"value"`
	TTL   time.Duration `firestore:"ttl"`
}

CacheEntity is a model for Firestore that handles cache with ttl

type Feed

type Feed struct {
	Entry []FeedEntry `xml:"entry"`
}

type FeedEntry

type FeedEntry struct {
	ID      string `xml:"id"`
	VideoID string `xml:"videoId"`
	Title   string `xml:"title"`
	Link    struct {
		Text string `xml:",chardata"`
		Rel  string `xml:"rel,attr"`
		Href string `xml:"href,attr"`
	} `xml:"link"`
	Published string `xml:"published"`
	Group     struct {
		Thumbnail struct {
			URL    string `xml:"url,attr"`
			Width  string `xml:"width,attr"`
			Height string `xml:"height,attr"`
		} `xml:"thumbnail"`
		Description string `xml:"description"`
	} `xml:"group"`
}

type YouTubeAPIRepository

type YouTubeAPIRepository struct {
	// contains filtered or unexported fields
}

func NewYouTubeAPIRepository

func NewYouTubeAPIRepository(yt *youtube.Service) YouTubeAPIRepository

func (YouTubeAPIRepository) GetChannel

func (YouTubeAPIRepository) ListChannel

func (yt YouTubeAPIRepository) ListChannel(ctx context.Context, query string) ([]app.YouTubeChannel, error)

type YouTubeRepository

type YouTubeRepository struct {
	FeedURL    *url.URL
	HTTPClient *http.Client
}

func NewYouTubeRepository

func NewYouTubeRepository() (YouTubeRepository, error)

func (YouTubeRepository) ListEntry

func (y YouTubeRepository) ListEntry(ctx context.Context, channelID string) ([]app.YouTubeFeedEntry, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL