p

package module
v0.0.0-...-a065f1c Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 20 Imported by: 0

README

Update Wallpapers Function

This function requests wallpapers for different countries using the Bing Wallpapers API.

Wallpapers get added if both the 1920x1080 and the 1920x1200 images exist and are not already in the database (Firestore).

For non-English countries, the descriptions are translated into English using the Google Translate API.

Finally, the images are annotated using the Google Vision API. This allows wallpapers to be searched by these labels in the future and provide better SEO.

If previously stored, translated English wallpapers appear again but in English, then the descriptions are replaced but original date is kept.

There is also splitting of the description to get the title and copyright.

Improvements

  • Separate the functions into different packages and enable CI/CD. They were originally kept in one file for ease of deployment.
  • TEST!
  • Merge with API source code (maybe).
  • Use concurrency for making requests (maybe).
  • Download wallpaper even if large image is not found.
  • Use IAM roles instead of service account keys.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ENMarkets = []string{
		"en-gb",
		"en-us",
		"en-ca",
		"en-au",
		"en-nz",
	}
)

Functions

func HelloPubSub

func HelloPubSub(ctx context.Context, m PubSubMessage) error

func Start

func Start(ctx context.Context, bucket *storage.BucketHandle) error

Types

type BingImage

type BingImage struct {
	StartDate string `json:"startdate"`
	Copyright string `json:"copyright"`
	URLBase   string `json:"urlbase"`
	URL       string `json:"url"`
}

type BingWallpapers

type BingWallpapers struct {
	Images []BingImage `json:"images"`
}

type Image

type Image struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Copyright string `json:"copyright"`
	Date      int    `json:"date"`
	Filename  string `json:"filename"`
	Market    string `json:"market"`
	FullDesc  string `json:"fullDesc"`
	URL       string `json:"url"`
	ThumbURL  string `json:"thumbUrl"`
}

type PubSubMessage

type PubSubMessage struct {
	Data []byte `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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