popcorntime_search 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49e7075c8bf5dbe93df96956e4b2fb99e8b36b54df480ee25bf93ff8d6cb3426
4
- data.tar.gz: e328b6e57dccf5f9c8af9034280cca24864df05e5f3b68b5b18200326bb676fc
3
+ metadata.gz: b9ca6f0d13691ab7be8b7661491aa8fb8418a56ab61c0979d4deccb9cadedf05
4
+ data.tar.gz: 33b327b652761b235195d08d2c52981d1bb5fd46f244b4264bcd5580a4218b9d
5
5
  SHA512:
6
- metadata.gz: 19e7546fc3ff15e8c5aaeaf339de9921af26e30bae41553fcaffb9064d1cb21d72ae0f9e7b6ee8107ad852d0935a004f82ae6c23ca97f24c04080f4a65024742
7
- data.tar.gz: 4fd058f5a1a2b951b7507f18c9824d21c677baa466b5c1a6801a7b9c2061acc39df16bdeefb126e7a04e72eb1753a22828b24fe537cefd5df18755b07ac502cb
6
+ metadata.gz: 6e895eaa271d33949815d0b3ad6692e9aeeb0c76f2d0db26e2ac5f6e2e91b8d6832de25e283ea22a4b4db7482253461289586b290d0546a109a33eaa5589b76c
7
+ data.tar.gz: d3efa522f3a729b1736b8a2a58ac909202b771ee3f54b1aa6926c8386972f01e430d16b2359b843348a4e32ef19679ed03b71b0abd43286fac3a87bfc4bdd8b8
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'bundler/setup'
4
- require 'factory_girl'
4
+ require 'factory_bot'
5
5
  require 'popcorntime_search'
6
6
  require 'pry'
7
7
 
@@ -11,6 +11,7 @@ FactoryBot.find_definitions
11
11
 
12
12
  # search = build(:search)
13
13
  # movie = build(:movie_result)
14
- show = build(:show_result)
14
+ # show = build(:show_result)
15
+ season = build(:show_result, :full_season)
15
16
 
16
17
  Pry.start
@@ -62,17 +62,20 @@ begin
62
62
 
63
63
  links = result.links.sort.reverse # Sort by number of seeds desc
64
64
 
65
- if options[:auto]
66
- link = links.first
65
+ if search.full_season?
66
+ say links.map(&:magnet).join("\n")
67
+ elsif options[:auto]
68
+ say links.first.magnet
67
69
  else
68
70
  say "Choose a link for #{result.to_s.blue}:".yellow
71
+
69
72
  link = choose(*links) do |menu|
70
73
  menu.default = '1'
71
74
  menu.select_by = :index_or_name
72
75
  end
73
- end
74
76
 
75
- say link.magnet
77
+ say link.magnet
78
+ end
76
79
  rescue Interrupt, EOFError
77
80
  say 'Interrupted!'.red
78
81
  rescue SocketError
@@ -1,5 +1,5 @@
1
1
  module PopcorntimeSearch
2
2
  BASE_URL = 'https://tv-v2.api-fetch.website'.freeze
3
- SEASON_EPISODE_REGEXP = /s(?<season>\d{1,2})e(?<episode>\d{1,2})|(?<season>\d{1,2})x(?<episode>\d{1,2})/i
4
- TITLE_REGEXP = /(?<showname>['\w\s\.]+?)[\s\.-]*?(#{SEASON_EPISODE_REGEXP}|$)/i
3
+ SEASON_EPISODE_REGEXP = /s(?<season>\d{1,2})(e(?<episode>\d{1,2}))?|(?<season>\d{1,2})x(?<episode>\d{1,2})/i.freeze
4
+ TITLE_REGEXP = /(?<showname>['\w\s\.]+?)[\s\.-]*?(#{SEASON_EPISODE_REGEXP}|$)/i.freeze
5
5
  end
@@ -15,7 +15,7 @@ module PopcorntimeSearch
15
15
  @season = season.to_i if season
16
16
  @episode = episode.to_i if episode
17
17
 
18
- @kind = @season && @episode ? :show : :movie
18
+ @kind = @season ? :show : :movie
19
19
  end
20
20
 
21
21
  def results
@@ -34,5 +34,9 @@ module PopcorntimeSearch
34
34
  rescue SocketError
35
35
  @results_found = false
36
36
  end
37
+
38
+ def full_season?
39
+ @season && !@episode
40
+ end
37
41
  end
38
42
  end
@@ -15,6 +15,10 @@ module PopcorntimeSearch
15
15
  private
16
16
 
17
17
  def build_links
18
+ @episode ? build_episode_links : build_season_links
19
+ end
20
+
21
+ def build_episode_links
18
22
  episode_links = self.class.get("/#{@imdb_id}")['episodes'].find do |episode|
19
23
  episode['season'] == @season && episode['episode'] == @episode
20
24
  end
@@ -22,7 +26,6 @@ module PopcorntimeSearch
22
26
  return [] unless episode_links
23
27
 
24
28
  episode_links['torrents'].each_with_object([]) do |(quality, info), links_list|
25
- next if quality == '0'
26
29
  links_list << Link.new(title: "#{@title} #{@season}x#{@episode.to_s.rjust(2, '0')}",
27
30
  imdb_id: imdb_id,
28
31
  magnet: info['url'],
@@ -33,5 +36,28 @@ module PopcorntimeSearch
33
36
  provider: info['provider'])
34
37
  end
35
38
  end
39
+
40
+ def build_season_links
41
+ season_links = self.class.get("/#{@imdb_id}")['episodes'].select do |episode|
42
+ episode['season'] == @season
43
+ end
44
+
45
+ return [] unless season_links
46
+
47
+ season_links.each_with_object([]) do |episode_info, links_list|
48
+ episode = episode_info['episode']
49
+
50
+ quality, info = episode_info['torrents'].max_by { |quality, _| quality.to_i }
51
+
52
+ links_list << Link.new(title: "#{@title} #{@season}x#{episode.to_s.rjust(2, '0')}",
53
+ imdb_id: imdb_id,
54
+ magnet: info['url'],
55
+ seeders: info['seeds'],
56
+ leechers: info['peers'],
57
+ language: 'en',
58
+ quality: quality,
59
+ provider: info['provider'])
60
+ end
61
+ end
36
62
  end
37
63
  end
@@ -1,3 +1,3 @@
1
1
  module PopcorntimeSearch
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popcorntime_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Marchante
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-10 00:00:00.000000000 Z
11
+ date: 2019-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  - !ruby/object:Gem::Version
255
255
  version: '0'
256
256
  requirements: []
257
- rubygems_version: 3.0.3
257
+ rubygems_version: 3.0.6
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: Search the popcorn-api https://github.com/popcorn-official/popcorn-api