iyoutu 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/README.md +58 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/iyoutu +57 -0
- data/iyoutu.gemspec +31 -0
- data/lib/iyoutu.rb +28 -0
- data/lib/iyoutu/version.rb +3 -0
- data/lib/iyoutu/youtube_dl_formats.rb +36 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5560b195a023b6afdf1958aab49dc6a55749f36c1feaa4e1489eb100980687f9
|
4
|
+
data.tar.gz: 53f66ef087bd7b6ea89a4a67dc5493bbccd910f2a585227c4686248a9a3bafdd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91c31949e34711412bd4a5f9ccf1d7a61656caf8a404c7ac6ac8f2ec2495f2d4cf92c2149da223167c2409b97fd499630415c13f3d244d7ddc72fe65c9c71de7
|
7
|
+
data.tar.gz: 76ffa39d2c779941d8f263fcb83bae37b10476b8fa0ce64c54c87dc62394a174bf0cf1ea6fa677c5765b5b2cba61b176d81a39cd9788e776496ee4d987aa12f3
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at felix.wolfsteller@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Iyoutu
|
2
|
+
|
3
|
+
Iyoutu is an extremely and limited wrapper around https://github.com/rg3/youtube-dl, allowing to interactively choose (in a terminal) which format to download.
|
4
|
+
|
5
|
+
Copyright 2019, Felix Wolfsteller
|
6
|
+
Released under the GPL (see LICENSE file).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'iyoutu'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install iyoutu
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Call as
|
27
|
+
|
28
|
+
iyoutu URL
|
29
|
+
|
30
|
+
where URL is the path to a source from which to download (possible sources are documented [in the youtube-dl documentation](http://rg3.github.io/youtube-dl/supportedsites.html)).
|
31
|
+
|
32
|
+
Make sure that you already have youtube-dl somewhere on your PATH and that you know what you are doing with it.
|
33
|
+
|
34
|
+
Example:
|
35
|
+
|
36
|
+
➜ $ ✗ iyoutu https://www.youtube.com/watch\?v\=anyvideoid
|
37
|
+
Select format (audio and video combined)
|
38
|
+
3gp/176x144 small 38k , mp4v.20.3, mp4a.40.2@ 24k (22050Hz), 24.08MiB
|
39
|
+
3gp/320x180 small 95k , mp4v.20.3, mp4a.40.2 (22050Hz), 58.90MiB
|
40
|
+
‣ webm/640x360 medium , vp8.0, vorbis@128k, 92.47MiB
|
41
|
+
mp4/640x360 medium 200k , avc1.42001E, mp4a.40.2@ 96k (44100Hz), 123.99MiB
|
42
|
+
mp4/1280x720 hd720 176k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)
|
43
|
+
-> Download audio and video seperately
|
44
|
+
! Abort
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
49
|
+
|
50
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fwolfst/iyoutu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
55
|
+
|
56
|
+
## Code of Conduct
|
57
|
+
|
58
|
+
Everyone interacting in the Iyoutu project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/iyoutu/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "iyoutu"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/iyoutu
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "iyoutu"
|
4
|
+
require 'tty-prompt'
|
5
|
+
|
6
|
+
#require 'clipboard'
|
7
|
+
#puts "Clipboard content: #{Clipboard.paste}"
|
8
|
+
|
9
|
+
if ARGV.length != 1
|
10
|
+
STDERR.puts "Need an argument (URL to fetch)"
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
video_url = ARGV[0]
|
15
|
+
|
16
|
+
youtube_dl_path = "youtube-dl"
|
17
|
+
|
18
|
+
formats_out = %x{#{youtube_dl_path} -F #{video_url}}
|
19
|
+
formats = Iyoutu::YoutubeDLFormats.new(formats_out)
|
20
|
+
choices = formats.video_with_audio.map do |format|
|
21
|
+
{
|
22
|
+
name: "#{format.extension}/#{format.resolution_note}",
|
23
|
+
value: format.format_code
|
24
|
+
}
|
25
|
+
end
|
26
|
+
choices << {
|
27
|
+
name: "-> Download audio and video seperately",
|
28
|
+
value: :separate
|
29
|
+
}
|
30
|
+
choices << Iyoutu::ABORT_CHOICE
|
31
|
+
|
32
|
+
prompt = TTY::Prompt.new
|
33
|
+
choice = prompt.select("Select format (audio and video combined)",
|
34
|
+
choices,
|
35
|
+
echo: false,
|
36
|
+
filter: true,
|
37
|
+
per_page: choices.length)
|
38
|
+
|
39
|
+
if choice == :abort
|
40
|
+
exit 0
|
41
|
+
elsif choice == :separate
|
42
|
+
video_choice = Iyoutu::user_choose_format(prompt,
|
43
|
+
"Video format",
|
44
|
+
formats.video_only)
|
45
|
+
exit 0 if video_choice == :abort
|
46
|
+
|
47
|
+
audio_choice = Iyoutu::user_choose_format(prompt,
|
48
|
+
"Audio format",
|
49
|
+
formats.audio_only)
|
50
|
+
exit 0 if audio_choice == :abort
|
51
|
+
|
52
|
+
exec "#{youtube_dl_path} -f #{video_choice}+#{audio_choice} #{video_url}"
|
53
|
+
else
|
54
|
+
exec "#{youtube_dl_path} -f #{choice} #{video_url}"
|
55
|
+
end
|
56
|
+
|
57
|
+
exit 0
|
data/iyoutu.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "iyoutu/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "iyoutu"
|
8
|
+
spec.version = Iyoutu::VERSION
|
9
|
+
spec.authors = ["Felix Wolfsteller"]
|
10
|
+
spec.email = ["felix.wolfsteller@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Interactive wrapper around youtube-dl}
|
13
|
+
spec.description = %q{Wrapper around youtube-dl, lets you choose formats}
|
14
|
+
spec.homepage = "https://github.com/fwolfst/iyoutu"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "tty-prompt"
|
26
|
+
#spec.add_dependency "clipboard" TODO
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
31
|
+
end
|
data/lib/iyoutu.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'iyoutu/version'
|
2
|
+
require 'iyoutu/youtube_dl_formats'
|
3
|
+
|
4
|
+
module Iyoutu
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
ABORT_CHOICE = {
|
8
|
+
name: "! Abort",
|
9
|
+
value: :abort
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.user_choose_format(prompt, question, formats)
|
13
|
+
choices = formats.map do |format|
|
14
|
+
{
|
15
|
+
name: "#{format.extension}/#{format.resolution_note}",
|
16
|
+
value: format.format_code
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
choices << ABORT_CHOICE
|
21
|
+
|
22
|
+
prompt.select(question,
|
23
|
+
choices,
|
24
|
+
echo: false,
|
25
|
+
filter: true,
|
26
|
+
per_page: choices.length)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Iyoutu
|
2
|
+
Format = Struct.new(:format_code, :extension, :resolution_note)
|
3
|
+
class YoutubeDLFormats
|
4
|
+
attr_accessor :formats_output
|
5
|
+
attr_accessor :video_only
|
6
|
+
attr_accessor :audio_only
|
7
|
+
attr_accessor :video_with_audio
|
8
|
+
|
9
|
+
def initialize(formats_output)
|
10
|
+
@formats_output = formats_output
|
11
|
+
@video_only = []
|
12
|
+
@audio_only = []
|
13
|
+
@video_with_audio = []
|
14
|
+
|
15
|
+
formats_output_lines = formats_output.split("\n")
|
16
|
+
# Partition formats
|
17
|
+
formats_output_lines.each do |line|
|
18
|
+
if line =~ /audio only/
|
19
|
+
@audio_only << parse_format_line(line)
|
20
|
+
elsif line =~ /video only/
|
21
|
+
@video_only << parse_format_line(line)
|
22
|
+
elsif line =~ /^(\d+).*$/ # line starts with number(s)
|
23
|
+
@video_with_audio << parse_format_line(line)
|
24
|
+
else
|
25
|
+
# skip
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_format_line(line)
|
31
|
+
format_line_regexp = /^(?<format_code>\d+) +(?<extension>[[:alnum:]]+) +(?<resolution_note>.*)$/
|
32
|
+
matches = format_line_regexp.match(line)
|
33
|
+
Format.new(matches[:format_code], matches[:extension], matches[:resolution_note])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iyoutu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felix Wolfsteller
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tty-prompt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description: Wrapper around youtube-dl, lets you choose formats
|
70
|
+
email:
|
71
|
+
- felix.wolfsteller@gmail.com
|
72
|
+
executables:
|
73
|
+
- iyoutu
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- exe/iyoutu
|
86
|
+
- iyoutu.gemspec
|
87
|
+
- lib/iyoutu.rb
|
88
|
+
- lib/iyoutu/version.rb
|
89
|
+
- lib/iyoutu/youtube_dl_formats.rb
|
90
|
+
homepage: https://github.com/fwolfst/iyoutu
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.7.7
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Interactive wrapper around youtube-dl
|
113
|
+
test_files: []
|