Giter Site home page Giter Site logo

metatube-community / metatube-sdk-go Goto Github PK

View Code? Open in Web Editor NEW
558.0 4.0 84.0 1.44 MB

MetaTube SDK/Web Server in Golang

Home Page: https://metatube-community.github.io/

License: Apache License 2.0

Go 98.71% Dockerfile 0.16% Makefile 1.13%
gin gorm pigo-face-detection postgresql scraper-engine sqlite go-colly emby jellyfin cloudnative

metatube-sdk-go's Introduction

MetaTube SDK Go

Build Status Go Report Card Require Go Version GitHub License Tag

Metadata Tube SDK in Golang.

Contents

Features

  • Supported platforms
    • Linux
    • Darwin
    • Windows
    • BSD(s)
  • Supported Databases
  • Image processing
    • Auto cropping
    • Badge support
    • Face detection
    • Image hashing
  • RESTful API
  • 20+ providers
  • Text translation

Installation

To install this package, you first need Go installed (version 1.21+ is required), then you can use the below Go command to install SDK.

go get -u github.com/metatube-community/metatube-sdk-go

Quickstart

# assume the following codes in example.go file
$ cat example.go
package main

import (
	"fmt"
	"log"

	"github.com/metatube-community/metatube-sdk-go/engine"
)

func main() {
	app := engine.Default()

	results, err := app.SearchMovieAll("<movie_id>", false)
	if err != nil {
		log.Fatal(err)
	}

	for _, result := range results {
		fmt.Println(result.Provider, result.ID, result.Number, result.Title)
	}
}
# run example.go and see output on console
$ go run example.go

API Examples

You can find detailed examples in examples folder or specific implementations in cmd folder.

Initiate SDK engine manually

package main

import (
	"log"
	"time"

	"github.com/metatube-community/metatube-sdk-go/database"
	"github.com/metatube-community/metatube-sdk-go/engine"
)

func main() {
	// Open database using in-memory SQLite.
	db, _ := database.Open(&database.Config{
		DSN:		  ":memory:",
		PreparedStmt: false,
	})

	// Allocate app engine with request timeout set to one minute.
	app := engine.New(db, time.Minute)

	// Initiate DB tables, only required at the first time.
	if err := app.AutoMigrate(true); err != nil {
		log.Fatal(err)
	}
}

Search and get actor info

func main() {
	app := engine.Default()
	
	// Search actor from Xs/List with fallback enabled.
	app.SearchActor("<actor_name>", xslist.Name, true)
	
	// Search actor from all available providers with fallback enabled.
	app.SearchActorAll("<actor_name>", true)
	
	// Get actor metadata id from Xs/List with lazy enabled.
	app.GetActorInfoByProviderID(xslist.Name, "<id>", true)
	
	// Get actor metadata from given URL with lazy enabled.
	app.GetActorInfoByURL("https://<actor_page_url>", true)
}

Search and get movie info

func main() {
	app := engine.Default()
	
	// Search movie from JavBus with fallback enabled.
	app.SearchMovie("<movie_id>", javbus.Name, true)
	
	// Search movie from all available providers with fallback enabled.
	// Option fallback will search the database for movie info if the corresponding providers
	// fail to return valid metadata.
	app.SearchMovieAll("<movie_id>", true)
	
	// Get movie metadata id from ARZON with lazy enable.
	// With the lazy option set to true, it will first try to search the database and return
	// the info directly if it exists. If the lazy option is set to false, it will fetch info
	// from the given provider and update the database.
	app.GetMovieInfoByProviderID(arzon.Name, "<id>", true)
	
	// Get movie metadata from given URL with lazy enabled.
	app.GetMovieInfoByURL("https://<movie_page_url>", true)
}

Get actor and movie images

func main() {
	app := engine.Default()
	
	// Get actor primary image id from Xs/List.
	app.GetActorPrimaryImage(xslist.Name, "<id>")
	
	// Get movie primary image id from FANZA with aspect ratio and pos set to default.
	app.GetMoviePrimaryImage(fanza.Name, "<id>", -1, -1)
	
	// Get movie primary image id from FANZA with aspect ratio set to 7:10 and pos
	// set to the center.
	app.GetMoviePrimaryImage(fanza.Name, "<id>", 0.70, 0.5)
	
	// Get movie backdrop image id from SOD.
	app.GetMovieBackdropImage(sod.Name, "<id>")
}

Text translate engine

package main

import (
	"github.com/metatube-community/metatube-sdk-go/translate"
)

func main() {
	var (
		appId  = "XXX"
		appKey = "XXX"
	)
	// Translate `Hello` from auto to Japanese by Baidu.
	translate.BaiduTranslate("Hello", "auto", "ja", appId, appKey)

	var apiKey = "XXX"
	// Translate `Hello` from auto to simplified Chinese by Google.
	translate.GoogleTranslate("Hello", "auto", "zh-cn", apiKey)
}

Credits

Library Description
gocolly/colly Elegant Scraper and Crawler Framework for Golang
gin-gonic/gin Gin is a HTTP web framework written in Go
gorm.io/gorm The fantastic ORM library for Golang
esimov/pigo Fast face detection, pupil/eyes localization and facial landmark points detection library in pure Go
robertkrimen/otto A JavaScript interpreter in Go (golang)
modernc.org/sqlite Package sqlite is a CGo-free port of SQLite/SQLite3
corona10/goimagehash Go Perceptual image hashing package
antchfx/xpath XPath package for Golang, supports HTML, XML, JSON document query

License

Apache-2.0 License

metatube-sdk-go's People

Contributors

dependabot[bot] avatar jasmineamber avatar xjasonlyu avatar zijiren233 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

metatube-sdk-go's Issues

[Feature] Add Genres to Search For Filtering out Certain Categories

Description

Add Genres to Search For Filtering out Certain Categories (omni, collection)
I believe I see where the code is needed, for example below on the fanza.go file:
Additionally the model needs to be updated on model/movie.go

I'm just not sure what the value below should be

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

results = append(results, &model.MovieSearchResult{
	ID:          id,
	Number:      ParseNumber(id),
	Title:       e.ChildAttr(`.//p[@class="tmb"]/a/span[1]/img`, "alt"),
	Provider:    fz.Name(),
	Homepage:    homepage,
	ThumbURL:    e.Request.AbsoluteURL(thumb),
	CoverURL:    e.Request.AbsoluteURL(PreviewSrc(thumb)),
	Score:       parser.ParseScore(rate /* float or a dash (-) */),
	ReleaseDate: parser.ParseDate(releaseDate /* 発売日:2022/07/21 */),
	Genres: [CODE HERE]
})

[Feature]

Description

jellyfin docker搭建的服务端 开始刮削后会日志报错
[2023-02-28 06:41:18.432 +00:00] [ERR] [76] MediaBrowser.Providers.Movies.MovieMetadataService: Error in "MetaTube"
System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.ReadAllAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
at Jellyfin.Plugin.MetaTube.ApiClient.GetDataAsync[T](String url, Boolean requireAuth, CancellationToken cancellationToken)
at Jellyfin.Plugin.MetaTube.ApiClient.SearchMovieAsync(String q, String provider, Boolean fallback, CancellationToken cancellationToken)
at Jellyfin.Plugin.MetaTube.ApiClient.SearchMovieAsync(String q, String provider, CancellationToken cancellationToken)
at Jellyfin.Plugin.MetaTube.Providers.MovieProvider.GetSearchResults(MovieInfo info, CancellationToken cancellationToken)
at Jellyfin.Plugin.MetaTube.Providers.MovieProvider.GetMetadata(MovieInfo info, CancellationToken cancellationToken)
at MediaBrowser.Providers.Manager.MetadataService2.ExecuteRemoteProviders(MetadataResult1 temp, String logName, TIdType id, IEnumerable`1 providers, CancellationToken cancellationToken)

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

[Feature] Docker image for armv7

Description

The processor of my raspberry pi is armv7. And sadly there's only a docker image manifest for linux/arm64 now😣
image
👆This doesn't help btw

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

Compile under amv7 environment and add a new manifest file before pushing the image to the registry🤔

请问如何修改刮削源的优先级呢

Description

部署了自用后端,刮削一直默认使用ARZON,怎么修改为JAVBUS?

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.