├── .github ├── goreleaser.yml └── workflows │ └── release.yml ├── .gitignore ├── Dockerfile ├── Procfile ├── README.md ├── app.json ├── go.mod ├── go.sum ├── heroku.yml ├── main.go ├── run.sh ├── text.txt └── watermark.jpg /.github/goreleaser.yml: -------------------------------------------------------------------------------- 1 | builds: 2 | - env: 3 | - CGO_ENABLED=0 4 | ldflags: 5 | - -s -w 6 | goos: 7 | - linux 8 | - darwin 9 | - windows 10 | goarch: 11 | - 386 12 | - amd64 13 | - arm 14 | - arm64 15 | goarm: 16 | - 6 17 | - 7 18 | archives: 19 | - format: gz 20 | files: 21 | - none* 22 | changelog: 23 | sort: asc 24 | filters: 25 | exclude: 26 | - "^docs:" 27 | - "^test:" 28 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - "v*" 5 | watch: 6 | types: started 7 | 8 | name: CI 9 | jobs: 10 | release: 11 | name: Release 12 | runs-on: ubuntu-latest 13 | if: github.event.repository.owner.id == github.event.sender.id 14 | steps: 15 | - name: Check out code 16 | uses: actions/checkout@master 17 | - name: goreleaser 18 | uses: docker://goreleaser/goreleaser:latest 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | with: 22 | args: release --config .github/goreleaser.yml 23 | if: success() 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | *.iml 14 | .idea 15 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM heroku/heroku:18 2 | 3 | RUN apt-get update && apt-get install -y ffmpeg 4 | 5 | WORKDIR /root 6 | 7 | COPY . . 8 | 9 | RUN curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /bin/youtube-dl 10 | RUN curl -sSL https://github.com/cxjava/j2ee/releases/download/v0.0.2/simhei.ttf -o /root/simhei.ttf 11 | RUN curl -sSL $(curl -sSL https://api.github.com/repos/cxjava/goreman/releases | grep browser_download_url | grep 'linux_amd64' | head -n 1 | cut -d '"' -f 4) | zcat > /bin/goreman 12 | RUN curl -sSL $(curl -sSL https://api.github.com/repos/cxjava/heroku-aria2c-youtube-dl/releases | grep browser_download_url | grep 'linux_amd64' | head -n 1 | cut -d '"' -f 4) | zcat > /bin/heroku-aria2c-youtube-dl 13 | RUN curl -sSL https://downloads.rclone.org/v1.51.0/rclone-v1.51.0-linux-amd64.zip -o /root/rclone-v1.51.0-linux-amd64.zip && unzip -n /root/rclone-v1.51.0-linux-amd64.zip -d /bin && mv /bin/rclone-v1.51.0-linux-amd64/rclone /bin/rclone 14 | 15 | RUN chmod +x /bin/goreman /root/run.sh /bin/heroku-aria2c-youtube-dl /bin/rclone 16 | RUN chmod a+rx /bin/youtube-dl 17 | 18 | RUN useradd -m heroku 19 | USER heroku 20 | EXPOSE 5000 21 | COPY Procfile Procfile 22 | CMD goreman -b=$PORT start 23 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | server: heroku-aria2c-youtube-dl 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | shadowsocks-chisel 2 | ================== 3 | 4 | [shadowsocks](https://github.com/shadowsocks/shadowsocks-go) + [chisel](https://github.com/jpillora/chisel) = ❤❤ 5 | 6 | ### Getting started 7 | 8 | Use this button [![Heroku Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/cxjava/heroku-aria2c-youtube-dl) 9 | 10 | Or create a Heroku app manually: 11 | 12 | ``` 13 | $ heroku create 14 | $ heroku stack:set container 15 | $ heroku config:set CHISEL_AUTH=user:pass METHOD=rc4-md5 KEY=foobar 16 | $ git push heroku master 17 | ... 18 | remote: Verifying deploy... done. 19 | To https://git.heroku.com/damp-anchorage-82986.git 20 | * [new branch] master -> master 21 | ``` 22 | 23 | Connect your `chisel` client: 24 | 25 | ``` 26 | $ chisel client --auth user:pass --keepalive 50s https://damp-anchorage-82986.herokuapp.com 8388 27 | 2019/04/15 17:58:45 client: Connecting to wss://damp-anchorage-82986.herokuapp.com:443 28 | 2019/04/15 17:58:45 client: proxy#1:0.0.0.0:8388=>0.0.0.0:8388: Listening 29 | 2019/04/15 17:58:48 client: Fingerprint 86:20:15:f6:83:36:b4:90:c9:97:8b:6a:ca:9a:43:92 30 | 2019/04/15 17:58:50 client: Connected (Latency 471.311085ms) 31 | ``` 32 | 33 | Run `shadowsocks-local`: 34 | 35 | ``` 36 | $ shadowsocks-local -s 127.0.0.1 -p 8388 -m rc4-md5 -k foobar -l 1080 37 | 2019/04/15 17:59:35 available remote server 127.0.0.1:8388 38 | 2019/04/15 17:59:35 starting local socks5 server at :1080 ... 39 | ``` 40 | 41 | Point your SOCKS5 clients to `127.0.0.1:1080` 42 | 43 | ``` 44 | $ curl --socks5 127.0.0.1:1080 ifconfig.co 45 | 54.204.99.36 46 | ``` 47 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "youtube-dl", 3 | "description": "download youtube video", 4 | "stack": "container", 5 | "env": { 6 | "RCLONE_CONFIG": { 7 | "description": "Rclone config to mount in one line, replace line breaks with \"\\n\"", 8 | "required": false 9 | }, 10 | "RCLONE_DESTINATION": { 11 | "description": "Path to store your file in your Rclone drive. Must start with a forward slash.", 12 | "required": false 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cxjava/heroku-aria2c-youtube-dl 2 | 3 | go 1.14 4 | 5 | require github.com/gin-gonic/gin v1.6.2 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 5 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 6 | github.com/gin-gonic/gin v1.6.2 h1:88crIK23zO6TqlQBt+f9FrPJNKm9ZEr7qjp9vl/d5TM= 7 | github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= 8 | github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= 9 | github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= 10 | github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= 11 | github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= 12 | github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= 13 | github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= 14 | github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= 15 | github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= 16 | github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= 17 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 18 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 19 | github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= 20 | github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 21 | github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= 22 | github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= 23 | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= 24 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 25 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= 26 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 27 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= 28 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 29 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 30 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 31 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 32 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 33 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 34 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 35 | github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= 36 | github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= 37 | github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= 38 | github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= 39 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= 40 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 41 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 42 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 43 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 44 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 45 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 46 | gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= 47 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 48 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | web: Dockerfile 4 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "github.com/gin-gonic/gin" 7 | "net/http" 8 | "os" 9 | "os/exec" 10 | ) 11 | 12 | func main() { 13 | r := gin.Default() 14 | r.StaticFS("/root", http.Dir("/root/")) 15 | r.GET("/d", func(c *gin.Context) { 16 | uu := c.Query("url") 17 | 18 | go func(u string) { 19 | fmt.Println(u + " start!!!!") 20 | download(u) 21 | fmt.Println(u + " done!!!!") 22 | }(uu) 23 | 24 | c.JSON(200, gin.H{ 25 | "out": "ok", 26 | }) 27 | }) 28 | 29 | port := os.Getenv("PORT") 30 | if len(port) == 0 { 31 | port = "8080" 32 | } 33 | r.Run(":" + port) 34 | } 35 | 36 | func download(u string) { 37 | cc := "/root/run.sh " + u 38 | cmd := exec.Command("sh", "-c", cc) 39 | stderr, _ := cmd.StderrPipe() 40 | cmd.Start() 41 | 42 | scanner := bufio.NewScanner(stderr) 43 | scanner.Split(bufio.ScanLines) 44 | for scanner.Scan() { 45 | m := scanner.Text() 46 | fmt.Println(m) 47 | } 48 | cmd.Wait() 49 | } 50 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | videoUrl="$1" 4 | watermark="/root/watermark.jpg" 5 | textFile="/root/text.txt" 6 | fontFile="/root/simhei.ttf" 7 | filename=$(youtube-dl $videoUrl -f 'best[height<=1080]' --get-filename) 8 | 9 | watermark_name="${filename}_watermark.mp4" 10 | 11 | echo "Rclone config detected" 12 | echo -e "[DRIVE]\n$RCLONE_CONFIG" > rclone.conf 13 | 14 | youtube-dl ${videoUrl} -f 'best[height<=1080]' -v 15 | 16 | ffmpeg -i "${filename}" -i "${watermark}" -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-5:main_h-overlay_h-5:enable='lt(mod(t\,60)\,5)',drawtext=fontfile=${fontFile}:textfile=${textFile}:y=10:x=(w-text_w)/2:fontsize=34:fontcolor=yellow@0.5:enable='lt(mod(t\,60)\,5)'" "${watermark_name}" 17 | 18 | echo "start Rclone" 19 | rclone -v --config="rclone.conf" copy "${watermark_name}" "DRIVE:$RCLONE_DESTINATION" 2>&1 20 | 21 | rm -rf "${filename}" 22 | rm -rf "${watermark_name}" 23 | -------------------------------------------------------------------------------- /text.txt: -------------------------------------------------------------------------------- 1 | 视频号:恩仔双语成长记 2 | -------------------------------------------------------------------------------- /watermark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todokku/heroku-aria2c-youtube-dl/6c408f0bf808adb00bd7d1ab42ba6fae22368bb0/watermark.jpg --------------------------------------------------------------------------------