jackettrb 0.1.0

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
+ SHA256:
3
+ metadata.gz: 0dd371bf99d8af164a340e434ee9a91a45e629fccc76d754b6932be2ffa14fd3
4
+ data.tar.gz: 24cb7f2397ef1294b63f2bfcc134182c9d2ba4fb702af2818d0c857d02edb46f
5
+ SHA512:
6
+ metadata.gz: baeee6690dcfa15a8a2c29814e5a72abd4975eae2491954d4970df9c839d9000fc9ed9163634ae3ec3d04d52a66ce299aa2ec613dac29bb9502cc1ef46cfe01a
7
+ data.tar.gz: 1dcd804c7f99a5ad54e14d54b9731ac3cab3f8424f649c4b8fb8b6fbd6633fab73f2d5617578b5ae7bfe17ba34435e0131ac009f2190591aa0ba96b1323e45bc
data/.rubocop.yml ADDED
@@ -0,0 +1,25 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Style/FrozenStringLiteralComment:
13
+ Enabled: false
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Security/Open:
19
+ Enabled: false
20
+
21
+ Naming/MethodParameterName:
22
+ Enabled: false
23
+
24
+ Layout/LineLength:
25
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in jackettrb.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jackettrb (0.1.0)
5
+ rss (~> 0.2.9)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ minitest (5.15.0)
12
+ parallel (1.21.0)
13
+ parser (3.1.0.0)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ regexp_parser (2.2.0)
18
+ rexml (3.2.5)
19
+ rss (0.2.9)
20
+ rexml
21
+ rubocop (1.25.0)
22
+ parallel (~> 1.10)
23
+ parser (>= 3.1.0.0)
24
+ rainbow (>= 2.2.2, < 4.0)
25
+ regexp_parser (>= 1.8, < 3.0)
26
+ rexml
27
+ rubocop-ast (>= 1.15.1, < 2.0)
28
+ ruby-progressbar (~> 1.7)
29
+ unicode-display_width (>= 1.4.0, < 3.0)
30
+ rubocop-ast (1.15.1)
31
+ parser (>= 3.0.1.1)
32
+ ruby-progressbar (1.11.0)
33
+ unicode-display_width (2.1.0)
34
+
35
+ PLATFORMS
36
+ x86_64-linux
37
+
38
+ DEPENDENCIES
39
+ jackettrb!
40
+ minitest (~> 5.0)
41
+ rake (~> 13.0)
42
+ rubocop (~> 1.21)
43
+
44
+ BUNDLED WITH
45
+ 2.2.32
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Josh Burns
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Jackettrb
2
+
3
+ Lightweight interaction layer for Jackett API servers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your `Gemfile`.
8
+ ``` ruby
9
+ gem "jackettrb"
10
+ ```
11
+
12
+ Or install it manually via the `gem` cli.
13
+
14
+ ``` ruby
15
+ $ gem install jackettrb
16
+ ```
17
+
18
+
19
+ ## Usage
20
+
21
+ First you need to make an instance of `Jackettrb::Request`, the constructor will take
22
+ 2 to 3 arguments. The URL to your Target Jackett instance, The API key, and you can optionally
23
+ pass in `true` as the third argument to turn on _strict RSS parsing_ this will generate more errors
24
+ and is off by default as a result.
25
+
26
+ ``` ruby
27
+ require 'jackettrb'
28
+
29
+ req = Jackettrb::Request.new("https://127.0.0.1:9117", "MyApiKey123123")
30
+
31
+ ```
32
+
33
+ From here we can ask Jackett to query the indexers for a given search term like so
34
+
35
+ ``` ruby
36
+ req.query("Spiderman")
37
+ ```
38
+
39
+ You can also get a feed of all results with the aptly named `firehose`.
40
+
41
+ ``` ruby
42
+ req.firehose
43
+ ```
44
+
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "jackettrb"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/jackettrb.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jackettrb/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jackettrb"
7
+ spec.version = Jackettrb::VERSION
8
+ spec.authors = ["Josh Burns"]
9
+ spec.email = ["joshyburnss@gmail.com"]
10
+
11
+ spec.summary = "Ruby library to provide an interface to Jackett API servers"
12
+ spec.description = "Ruby library to provide an interface to Jackett API servers"
13
+ spec.homepage = "https://github.com/joshburnsxyz/jackettrb"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "rss", "~> 0.2.9"
32
+ end
@@ -0,0 +1,41 @@
1
+ require "net/http"
2
+ require "open-uri"
3
+ require "rss"
4
+
5
+ module Jackettrb
6
+ class Request
7
+ attr_accessor :strict, :host, :key
8
+
9
+ # rubocop:disable Style/OptionalBooleanParameter
10
+ def initialize(host, key, strict = false)
11
+ @key = key
12
+ @host = host
13
+ @strict = strict
14
+ end
15
+ # rubocop:enable Style/OptionalBooleanParameter
16
+
17
+ def firehose
18
+ url = parse_url(@host, nil)
19
+ parse_rss(url, @strict)
20
+ end
21
+
22
+ def query(q)
23
+ url = parse_url(@host, "&q=#{q}")
24
+ parse_rss(url, @strict)
25
+ end
26
+
27
+ private
28
+
29
+ def parse_url(host, params)
30
+ URI.parse("#{host}/api/v2.0/indexers/all/results/torznab/api?apikey=#{@key}#{params}")
31
+ end
32
+
33
+ def parse_rss(url, strict)
34
+ feed = nil
35
+ URI.open(url) do |rss|
36
+ feed = RSS::Parser.parse(rss, strict)
37
+ end
38
+ feed
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jackettrb
4
+ VERSION = "0.1.0"
5
+ end
data/lib/jackettrb.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "jackettrb/version"
4
+ require_relative "jackettrb/request"
5
+
6
+ module Jackettrb
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jackettrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Burns
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rss
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.9
27
+ description: Ruby library to provide an interface to Jackett API servers
28
+ email:
29
+ - joshyburnss@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rubocop.yml"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/rubocop
42
+ - bin/setup
43
+ - jackettrb.gemspec
44
+ - lib/jackettrb.rb
45
+ - lib/jackettrb/request.rb
46
+ - lib/jackettrb/version.rb
47
+ homepage: https://github.com/joshburnsxyz/jackettrb
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ homepage_uri: https://github.com/joshburnsxyz/jackettrb
52
+ source_code_uri: https://github.com/joshburnsxyz/jackettrb
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.2.32
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Ruby library to provide an interface to Jackett API servers
72
+ test_files: []