rmpv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d303d07c206862d0da837453a91ced468680ff6
4
+ data.tar.gz: b63b33e10c02eeb0eb206ca922473018fa35dd0d
5
+ SHA512:
6
+ metadata.gz: 3f449b4c42616aa8e8dfb67068a5af4b9055c4c6bf6abf2a879ac4b3ce9ceb9e2b947ffb7d053c11dd5c015cc75fc627c657e09d81f14601b40e9775b5d5d74a
7
+ data.tar.gz: 733a51f1aa02b0499e74956a1b2feb8f9476ab141212b1f8d575f38aa6d64a442312e1da8d6c91b2498aefafa78cae4f1e93328e30989ca1d416c58529fb877b
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ tags
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rmpv.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 rejuvyesh <mail@rejuvyesh.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ rmpv
2
+ ====
3
+
4
+ Ruby wrapper around [mpv](http://mpv.io/) with [trakt](http://trakt.tv) and [myanimelist](http://myanimelist.net) scrobble support.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'rmpv'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install rmpv
19
+
20
+ ## Usage
21
+
22
+ ~~~
23
+ Usage: rmpv [options]
24
+
25
+ -+, --vol=VOL increase volume by VOL
26
+ -l, --top-left play in top-left corner of the screen
27
+ -b, --bottom-right play in bottom-right corner of the screen
28
+ -x, --speed SPEED increase speed by SPEED
29
+ -s, --size STR set size of the player
30
+ -y, --youtube youtube mode
31
+ -a, --audio audio mode
32
+ -t, --trakt scrobble to trakt
33
+
34
+ ~~~
35
+
36
+ TODO: Write usage instructions here
37
+
38
+ ## Todo
39
+
40
+ - Add myanimelist scrobble support
41
+ - Use trakt scrobble rather than trakt seen for scrobbling. (This requires that we add scrobble support to [traktr](https://github.com/joelanford/traktr)).
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/rmpv ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ # Copyright rejuvyesh <mail@rejuvyesh.com>, 2013
4
+
5
+ require "shellwords"
6
+ require "to_name"
7
+ require "rmpv"
8
+
9
+ options = {
10
+ volume: 0,
11
+ speed: 1.0,
12
+ }
13
+
14
+ cmd = ["mpv"]
15
+
16
+ # save position on exit
17
+ cmd << "--save-position-on-quit"
18
+
19
+ pwd = Dir.pwd
20
+
21
+ # check if there is a .mp file in the current directory and add it as options
22
+
23
+ if File.exists? ".mp"
24
+ File.open(".mp", "r").each do |line|
25
+ ARGV << line.chomp
26
+ end
27
+ end
28
+
29
+ # parse options
30
+ cmd, options = Rmpv::Option.parse(ARGV, cmd, options)
31
+
32
+ cmd = Rmpv::Option.command(cmd, options)
33
+
34
+ # begin execution
35
+ file = Shellwords.shelljoin(ARGV)
36
+
37
+ mpv = cmd.join(" ") + " " + file
38
+
39
+ puts "running '#{mpv}'..."
40
+ system mpv
41
+
42
+ # mark as seen on trakt
43
+ if options[:trakt]
44
+ show = ToName.to_name(file)
45
+ trak = Rmpv::Trakt.new
46
+ trak.scrobble(show)
47
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ #
4
+ # File: myanimelist.rb
5
+ #
6
+ # Copyright rejuvyesh <mail@rejuvyesh.com>, 2013
7
+
8
+ module Rmpv
9
+
10
+ end
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ #
4
+ # File: option.rb
5
+ #
6
+ # Copyright rejuvyesh <mail@rejuvyesh.com>, 2013
7
+
8
+ require "optparse"
9
+
10
+ module Rmpv
11
+ class Option
12
+ def self.parse args, cmd, options
13
+ begin
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: rmpv [options]"
16
+
17
+ opts.on("-+", "--vol=VOL", Integer, "increase volume by VOL") do |v|
18
+ options[:volume] = v
19
+ end
20
+
21
+ opts.on("-l", "--top-left", "play in top-left corner of the screen") do |tl|
22
+ options[:position] = :top_left
23
+ end
24
+ opts.on("-b", "--bottom-right", "play in bottom-right corner of the screen") do |br|
25
+ options[:position] = :bottom_right
26
+ end
27
+ opts.on("-x", "--speed SPEED", Float, "increase speed by SPEED") do |x|
28
+ options[:speed] = x
29
+ end
30
+ opts.on("-s", "--size STR", "set size of the player") do |sa|
31
+ options[:size] = sa
32
+ end
33
+ opts.on("-y", "--youtube", "youtube mode") do |y|
34
+ options[:speed] = 1.5
35
+ cmd << "--cache-default=2048"
36
+ end
37
+ opts.on("-a", "--audio", "audio mode") do |a|
38
+ cmd << "--audio-display=no --gapless-audio"
39
+ end
40
+ opts.on("-t", "--trakt", "scrobble to trakt") do |t|
41
+ options[:trakt] = true;
42
+ end
43
+ end.parse!
44
+
45
+ rescue OptionParser::InvalidOption => e
46
+ cmd << e.to_s.sub(/^invalid option:\s+/, "")
47
+ end
48
+
49
+ return cmd, options
50
+ end
51
+
52
+ def self.command cmd, options
53
+ # size
54
+ if options[:size]
55
+ cmd << "--autofit='#{options[:size]}'"
56
+ end
57
+
58
+ if options[:position] == :top_left
59
+ cmd << "--geometry='0:17'"
60
+ elsif options[:position] == :bottom_right
61
+ cmd << "--geometry='100%:97%'"
62
+ end
63
+
64
+ # audio filter
65
+ # Remove chirping at higher speed
66
+ cmd << "--af=scaletempo"
67
+ if options[:volume].nonzero?
68
+ cmd << "--af=volume=#{options[:volume]}"
69
+ end
70
+
71
+ # speed increase
72
+ if options[:speed] != 1.0
73
+ cmd << "--speed=#{options[:speed]}"
74
+ end
75
+
76
+ return cmd
77
+ end
78
+ end
79
+ end
data/lib/rmpv/trakt.rb ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ #
4
+ # File: trakt.rb
5
+ #
6
+ # Copyright rejuvyesh <mail@rejuvyesh.com>, 2013
7
+
8
+ require "traktr"
9
+ require "yaml"
10
+
11
+ module Rmpv
12
+ class Trakt
13
+ def initialize
14
+ traktconfig = YAML.load File.open("#{Dir.home}/.traktrc")
15
+ @trakt = Traktr::Client.new(traktconfig["api_key"], traktconfig["username"], traktconfig["password"], true)
16
+ end
17
+ def scrobble show
18
+ tries = 5
19
+ begin
20
+ info = @trakt.search.shows(show.name)
21
+ @episodes = @trakt.show.season(info[0].title, show.series)
22
+ res = @trakt.show.episode.seen(info[0], @episodes[show.episode-1..show.episode-1])
23
+ puts "Scrobbled to trakt (Y)"
24
+ rescue Exception => e
25
+ tries -= 1
26
+ if tries > 0
27
+ retry
28
+ else
29
+ puts "Couldn't connect to trakt servers: #{res}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Rmpv
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rmpv.rb ADDED
@@ -0,0 +1,4 @@
1
+ # local libs
2
+ Dir["#{File.join(File.dirname(__FILE__), "rmpv")}/*.rb"].each do |lib|
3
+ require lib
4
+ end
data/rmpv.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rmpv/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rmpv"
8
+ spec.version = Rmpv::VERSION
9
+ spec.authors = ["rejuvyesh"]
10
+ spec.email = ["mail@rejuvyesh.com"]
11
+ spec.description = %q{Ruby wrapper for mpv}
12
+ spec.summary = %q{A ruby wrapper around mpv with trakt and myanimelist scobble support}
13
+ spec.homepage = "http://rejuvyesh.com/rmpv"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency "traktr"
25
+ spec.add_dependency "toname"
26
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rmpv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - rejuvyesh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: traktr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: toname
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby wrapper for mpv
70
+ email:
71
+ - mail@rejuvyesh.com
72
+ executables:
73
+ - rmpv
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - bin/rmpv
83
+ - lib/rmpv.rb
84
+ - lib/rmpv/myanimelist.rb
85
+ - lib/rmpv/option.rb
86
+ - lib/rmpv/trakt.rb
87
+ - lib/rmpv/version.rb
88
+ - rmpv.gemspec
89
+ homepage: http://rejuvyesh.com/rmpv
90
+ licenses:
91
+ - MIT
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.2.0
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: A ruby wrapper around mpv with trakt and myanimelist scobble support
113
+ test_files: []
114
+ has_rdoc: