To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit a3e33c62 authored by Christof Gerber's avatar Christof Gerber
Browse files

gitlab-ci: add .yml file. Set badges. Document requirements

parent b2de97fc
Pipeline #35002 failed with stages
in 3 minutes and 34 seconds
image: golang:1.12.4-alpine
cache:
# jobs of each branch always use the same cache
key: "${CI_COMMIT_REF_SLUG}"
untracked: true
paths:
- .cache
stages:
- test
- build
variables:
# Avoids missing gcc in exec path problem
CGO_ENABLED: "0"
before_script:
- apk add --update git make bash
- 'which ssh-agent || ( apk add --update openssh-client )'
- eval $(ssh-agent -s)
## tr to fix line endings which makes ed25519 keys work without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
- bash -c 'printf "%s\n" "$SSH_PRIVATE_KEY_GITLAB"' | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- git config --global url."ssh://git@gitlab.ethz.ch/".insteadOf "https://gitlab.ethz.ch/"
- git config --global user.email "gitlab-ci@composey.io"
- git config --global user.name "gitlab-ci composey"
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- mkdir -p /home/gotools
- git clone git@gitlab.ethz.ch:chgerber/gotools.git /home/gotools
- ln -sf /home/gotools/Makefile $CI_PROJECT_DIR/Makefile
- ln -sf /home/gotools/tools $CI_PROJECT_DIR/tools
# youtubedl specific
- wget "https://yt-dl.org/downloads/latest/youtube-dl" -O "/usr/local/bin/youtube-dl"
- chmod a+rx "/usr/local/bin/youtube-dl"
unit_tests:
stage: test
script:
- make test
#race_detector:
# stage: test
# script:
# - make race
#
#memory_sanitizer:
# stage: test
# script:
# - make msan
code_coverage:
stage: test
script:
- make coverage
#code_coverage_report:
# stage: test
# script:
# - make coverhtml
# only:
# - master
lint_code:
stage: test
script:
- make lint
build:
stage: build
script:
- make
\ No newline at end of file
# youtube-dl
# youtubedl
[![pipeline status](https://gitlab.ethz.ch/chgerber/youtubedl/badges/master/pipeline.svg)](https://gitlab.ethz.ch/chgerber/youtubedl/commits/master)
[![coverage report](https://gitlab.ethz.ch/chgerber/youtubedl/badges/master/coverage.svg)](https://gitlab.ethz.ch/chgerber/youtubedl/commits/master)
Go wrapper library for youtube-dl and YouTube Data API
### Requirements
* Env. variable `YOUTUBE_DATA_API_KEY` needs to be set.
* Binary `youtube-dl` needs to be callable.
### youtube-dl linux cli tool
Upon Errors make sure the most recent version is installed:
```bash
......
......@@ -9,5 +9,11 @@ require (
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.4.1
github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51 // indirect
google.golang.org/api v0.3.2
)
......@@ -90,10 +90,14 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
......@@ -103,6 +107,9 @@ golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
......@@ -111,6 +118,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
......@@ -121,12 +129,21 @@ golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb h1:zzdd4xkMwu/GRxhSUJaCPh4/j
golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e h1:Pzdi8HRppinixnWWzN6KSa0QkBM+GKsTJaWwwfJskNw=
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51 h1:RhYYBLDB5MoVkvoNGMNk+DSj7WoGhySvIvtEjTyiP74=
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/api v0.3.2 h1:iTp+3yyl/KOtxa/d1/JUE0GGSoR6FuW5udver22iwpw=
google.golang.org/api v0.3.2/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
......
......@@ -18,6 +18,7 @@ import (
"strings"
)
// SubtitleFormat type describes a subtitle type (e.g. `vtt`)
type SubtitleFormat string
func (sf SubtitleFormat) String() string {
......@@ -25,27 +26,35 @@ func (sf SubtitleFormat) String() string {
}
const (
SubVTT SubtitleFormat = "vtt"
SubSRT SubtitleFormat = "srt"
SubSSA SubtitleFormat = "ssa"
SubSTL SubtitleFormat = "stl"
// SubVTT caption of type vtt
SubVTT SubtitleFormat = "vtt"
// SubSRT caption of type srt
SubSRT SubtitleFormat = "srt"
// SubSSA caption of type ssa
SubSSA SubtitleFormat = "ssa"
// SubSTL caption of type stl
SubSTL SubtitleFormat = "stl"
// SubTTML caption of type ttml
SubTTML SubtitleFormat = "ttml"
)
// SupportedSubs contains all supported subtitle formats as key. Value is an empty string.
var SupportedSubs = map[SubtitleFormat]string{
//SubVTT: "",
//SubVTT: "", // TODO support vtt from YouTube with timestamp tags
SubSRT: "",
SubSSA: "",
SubSTL: "",
SubTTML: "",
}
// ErrYoutubeDLLangNotSupported is thrown when language not supported
type ErrYoutubeDLLangNotSupported string
func (e ErrYoutubeDLLangNotSupported) Error() string {
return string(e)
}
// ErrYoutubeDL are errors with related to the youtubedl pkg
type ErrYoutubeDL string
func (e ErrYoutubeDL) Error() string {
......@@ -99,6 +108,7 @@ type SubList struct {
Subtitles map[string][]string
}
// NewSubList creates a new reference to a SubList with empty members.
func NewSubList() *SubList {
return &SubList{
AutomaticCaptions: make(map[string][]string),
......
......@@ -10,9 +10,7 @@ import (
)
func TestGetPlaylistVideos(t *testing.T) {
log.SetLevel(log.TraceLevel)
assert.Equal(t, true, os.Getenv("YOUTUBE_DATA_API_KEY") != "")
videos, err := GetPlaylistVideos("PLpTJzCmGYaZFjE7jfH1tKFZt9rtqvvuj0", os.Getenv("YOUTUBE_DATA_API_KEY"))
assert.Equal(t, nil, err)
assert.Equal(t, 3, len(videos))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment