From 070dda8739423d7c1803a30243bd2a0e840b46fa Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Mon, 21 Sep 2020 19:12:23 +0200 Subject: [PATCH] add language detection for videos --- go.mod | 1 + go.sum | 2 ++ sources/youtubeVideo.go | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index da33ca3..8ac9d40 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ replace github.com/btcsuite/btcd => github.com/lbryio/lbrycrd.go v0.0.0-20200203 require ( github.com/Microsoft/go-winio v0.4.14 // indirect + github.com/abadojack/whatlanggo v1.0.1 github.com/asaskevich/govalidator v0.0.0-20200819183940-29e1ff8eb0bb github.com/aws/aws-sdk-go v1.25.9 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index 409d083..d682b4b 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/abadojack/whatlanggo v1.0.1 h1:19N6YogDnf71CTHm3Mp2qhYfkRdyvbgwWdd2EPxJRG4= +github.com/abadojack/whatlanggo v1.0.1/go.mod h1:66WiQbSbJBIlOZMsvbKe5m6pzQovxCH9B/K8tQB2uoc= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index 6118745..3d58747 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -12,6 +12,7 @@ import ( "sync" "time" + "github.com/abadojack/whatlanggo" "github.com/lbryio/ytsync/v5/downloader/ytdl" "github.com/lbryio/ytsync/v5/shared" @@ -409,7 +410,11 @@ func (v *YoutubeVideo) publish(daemon *jsonrpc.Client, params SyncParams) (*Sync FeeCurrency: jsonrpc.Currency(params.Fee.Currency), } } - + info := whatlanggo.Detect(v.getAbbrevDescription()) + if info.IsReliable() { + language := info.Lang.Iso6391() + languages = []string{language} + } options := jsonrpc.StreamCreateOptions{ ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ Title: &v.title,