Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Commit

Permalink
Add updates to downloader (#25)
Browse files Browse the repository at this point in the history
* Add github ci configs

* Add github action

* Update Dockerfile

* Add go modules for dep mgt

* Update gitigore

* Add issues template

* Update README

* Update licence

* Update main package

* Add main test

* Update main_tests

* Add video converter module

* Add video extraction sub module

* Add concurrent video stream extractor

* Update main program entry

* Update video extractor table test

* Remove dead code

* Update test files

* Remove vendor deps

* Update go mod deps

* Update makefile

* Add bug fixes to video downloader

* Add fixes to main test

* Add formatting directives to fmt sprintf

* Update go modules

* Update go lame api references

* Add vendor director

* Add bugfix to video converter
  • Loading branch information
Nyah authored Jan 3, 2020
1 parent c39efd1 commit 5df855f
Show file tree
Hide file tree
Showing 289 changed files with 245 additions and 149,760 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @ch3ck

7 changes: 7 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Tracking issue
about: Use this template for tracking new features.
title: "[DATE]: [FEATURE NAME]"
labels: bug, feature request, needs triage, won't fix
assignees: ch3ck
---
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Run Tests

on: [push, pull_request]


jobs:
setup-build-test:
name: Setup, Build, Test
strategy:
matrix:
go-version: [1.12.x, 1.13.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v1
- name: Build and run tests
run: make
27 changes: 11 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@
ytd
youtube-dl

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

# OSX
.DS_Store

# CODE coverage results
coverage.txt
profile.out

# ENV files
.envrc
.idea
47 changes: 0 additions & 47 deletions ARCHITECTURE.md

This file was deleted.

11 changes: 7 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Contributing to YTD
# Contributing to youtube-dl

Welcome to the YTD Dev team, we've been expecting you. YTD is an open source project and we greatly appreciate your help!
Welcome to the youtube-dl dev team, we've been expecting you.
youtube-dl is an open source project and we greatly appreciate your help!


## Filing Bugs

Please follow these guidelines when filing bugs to the project.
Please follow the github template when filing bugs.

* Indicate the version Go
* OS Architecture and other OS information
* Procedure to reproduce the bug
* Expected out and current output

For general questions catch me on the [Gophers Slack, #africa channel](https://invite.slack.golangbridge.org/) or on [twitter](https://twitter.com/nyah_check). For sensitive security-related issues should be reported to me directly[checko(mailto:[email protected]).
For general questions catch me on the [Gophers Slack, #africa channel](https://invite.slack.golangbridge.org/) or
on [twitter](https://twitter.com/nyah_check).
For sensitive security-related issues should be reported to me directly[checko(mailto:[email protected]).


## New Features and General code contribution
Expand Down
35 changes: 10 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
FROM golang:latest
FROM golang:latest AS go-base

RUN mkdir -p /go/src/github.com/Ch3ck/youtube-dl/
MAINTAINER Nyah Check <[email protected]>

WORKDIR /go/src/github.com/Ch3ck/youtube-dl
RUN apk add --no-cache \
ca-certificates \
make

COPY vendor vendor
COPY api api
COPY Makefile Makefile
COPY ytd.go .

RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o youtube-dl .


FROM alpine:latest

MAINTAINER Nyah Check <[email protected]>

ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go

RUN apk add --no-cache \
ca-certificates

WORKDIR /root/
COPY --from=0 /go/src/github.com/Ch3ck/youtube-dl .
FROM go-base
WORKDIR /go/src/github.com/ch3ck/youtube-dl
COPY . .
RUN make build

RUN echo "Image build complete."


CMD [ "./youtube-dl" ]
CMD [ "./youtube-dl" ]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 YTD
Copyright (c) 2020 youtube-dl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Builds and runs the micro services go generate && go build
#$ bin/%: CGO_ENABLED=0 go build -ldflags '-s -w' -tags netgo -v -o $@ ./cmd/$*
# Set an output prefix, which is the local directory if not specified
# Setup package name variables
NAME := ytd
PKG := github.com/ch3ck/$(NAME)
PREFIX?=$(shell pwd)
BUILDTAGS=

Expand All @@ -19,18 +19,18 @@ static:

fmt:
@echo "+ $@"
@gofmt -s -l -w . | grep -v vendor | tee /dev/stderr
@gofmt -s -l -w . | tee /dev/stderr

test:
@echo "+ $@"
@find . -name \*.mp3 -delete #clean previous test files.
@go test -v -tags "$(BUILDTAGS) cgo" $(shell go list ./... | grep -v vendor)
@go test -v -tags "$(BUILDTAGS) cgo" $(shell go list -m all)
@find . -name \*.mp3 -delete # clean previous test downloads
@go test -bench=. $(shell go list ./... | grep -v vendor)
@go test -bench=. $(shell go list -m all)

vet:
@echo "+ $@"
@go vet $(shell go list ./... | grep -v vendor)
@go vet $(shell go list -m all)

clean:
@echo "+ $@"
Expand Down
89 changes: 32 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,50 @@
# ytd
`ytd` is Go application for downloading Youtube videos and converting to other formats(flv, mp3). To understand the design take a look at the [Design Document](ARCHITECTURE.md).
# youtube-dl

```
.
├── api
│   ├── apiconv.go
│   ├── apidata.go
│   └── apidata_test.go
├── ARCHITECTURE.md
├── build.sh
├── cmd
│   └── ytd
│   ├── ytd.go
│   └── ytd_test.go
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── simple.go
└── vendor
....
```
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge)](https://godoc.org/github.com/ch3ck/youtube-dl)
[![Github All Releases](https://img.shields.io/github/downloads/ch3ck/youtube-dl/total.svg?style=for-the-badge)](https://github.com/ch3ck/youtube-dl/releases)

## Pre requisites

* [Go version 1.8](https://github.com/golang/go/releases/tag/go.1.8.3)
* [Docker CE 17.06](https://docs.docker.com/release-notes/docker-ce/)
* [Lame](https://sourceforge.net/projects/lame/)
`youtube-dl` is a simple youtube video downloader and can also download multiple videos concurrently.
Downloaded videos could be converted to `flv` or `mp3` formats.

Clone GIT repo and install some dependencies:
```
$ git clone https://github.com/Ch3ck/youtube-dl

```
## Dependencies

## Build
* [Go version 1.12](https://github.com/golang/go/releases/tag/go.1.12)
* [Docker CE 17.06](https://docs.docker.com/release-notes/docker-ce/)
* [Lame](https://sourceforge.net/projects/lame/)

The make command builds the code, runs the tests, generates and runs the docker containers.

```
## Build
```bash
$ git clone htps://github.com/Ch3ck/youtube-dl
$ cd youtube-dl
$ make
```

## Kickstart usage
## Usage

On a Linux or OSX system
```
ytd -id 'videoId' -format mp3 -bitrate 123 -path ~/Downloads/ videoUrlv0.1
-bitrate uint
Audio Bitrate (default 123)
-format string
File Format(mp3, webm, flv)
-id string
Youtube Video ID
-path string
Output Path (default ".")
-version
print version and exit
searches for youtube video on that link and downloads
```
Running `ytd` without any arguments will prompt for link.
```console
youtube-dl -h
youtube-dl - Simple youtube video/audio downloader

Usage: youtube-dl [OPTIONS] [ARGS]

Flags:
-bitrate Audio Bitrate (default 123)
-format File Format(mp3, webm, flv)
-id Youtube Video ID
-path Output Path (default ".")
-version print version and exit
-h Help page
```

## Roadmap

* Search for Youtube vidoes based on the Link and provides the download options for either mp3 or flv file.
* Download youtube video with video id or link and converts to flv or mp3.
* Support HD Video download.
* Multithreaded downloads.
* Concurrent downloads.
* Web App(PWA, Basic JS Web UI).
* Package for OSX, Android, iOS.


## Contributing
Expand All @@ -79,8 +53,9 @@ Start by starring and Forking this repository. Follow the basic instruction in t

## Licence

YTD is licensed under [The MIT Licence](LICENSE.md).
youtube-dl is licensed under [The MIT Licence](LICENSE.md).

## Author

This project was created and maintained by [Nyah Check](https://twitter.com/nyah_check). Please feel free to reach out, I could always use your help or advice. :-)
This project was created and maintained by [Nyah Check](https://twitter.com/ch3ck_).
Please feel free to reach out, I could always use your help or advice. :-)
13 changes: 8 additions & 5 deletions api/concurrency.go → concurrent_download.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package api
/**
* download video files concurrently
*/
package main

import "sync"

//DownloadStreams download a batch of elements asynchronouslly
func DownloadStreams(maxOperations int, format, outputPath string, bitrate uint, urls []string) <-chan error {
//DownloadStreams download a batch of elements asynchronously
func downloadStreams(maxOperations int, format, outputPath string, bitrate uint, urls []string) <-chan error {

var wg sync.WaitGroup
wg.Add(len(urls))
Expand All @@ -13,10 +16,10 @@ func DownloadStreams(maxOperations int, format, outputPath string, bitrate uint,
go func(url string) {
defer wg.Done()

if ID, err := GetVideoId(url); err != nil {
if ID, err := getVideoId(url); err != nil {
ch <- err
} else {
ch <- APIGetVideoStream(format, ID, outputPath, bitrate)
ch <- getVideoStream(format, ID, outputPath, bitrate)
}
}(url)
}
Expand Down
1 change: 1 addition & 0 deletions concurrent_download_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package main
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/ch3ck/youtube-dl

go 1.12

require (
github.com/sirupsen/logrus v1.4.2
github.com/viert/go-lame v0.0.0-20190822173615-801f1be8d24f
golang.org/x/sys v0.0.0-20200102141924-c96a22e43c9c // indirect
)
Loading

0 comments on commit 5df855f

Please sign in to comment.