eztv_scraper 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 21c20f4cdafc7389a10141ffb21bb2688a1f875c1f9d83e81aee8b8d9b6a0681
4
+ data.tar.gz: 26b2b237f2132f32d12f687d804300a3532139cb017a5ae0bc3274277107bb8d
5
+ SHA512:
6
+ metadata.gz: d07848e4bc4d2eb00d076a6bc97a97b44f6dac827cda87ee03342d8db6ef9d1a926910f59bb851c42fe170ee9f4e3b7692ddf428cea601b08825474aba4677a2
7
+ data.tar.gz: 01046e70701c10a1acfcb3ba212168aba826a0586fdf0f7fa5c3601b8d9fbb821e76f53204eae97e5be356fda7ec2dbcaa11f87c8fd70c0f8bcb3b827bc3e2ce
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,112 @@
1
+ # EZTV Scraper
2
+
3
+ > EZTV-Scraper looks for any selected show on eztv.io and saves magnet links of every single available episode into a JSON file.
4
+
5
+ ## Quick Start
6
+
7
+ Install the gem from RubyGems
8
+ `gem install eztv_scraper`
9
+
10
+ Run it anywhere
11
+ `eztv_scraper`
12
+
13
+ ---
14
+
15
+ ![Welcome](https://imgur.com/rhkE4jp.png)
16
+
17
+ The app heavily uses assets from TTY to beautify the interface.
18
+
19
+ ![welcome code](https://imgur.com/EGjUZD7.png)
20
+
21
+ Most of the app doesn't pass any values or parameters to each other. They simply take your selections and downloads the data you want.
22
+
23
+ ![Parsing the page](https://imgur.com/YdQC0Iu.png)
24
+
25
+ This module parses the websites.
26
+
27
+ ![enter image description here](https://imgur.com/NXXTvhZ.png)
28
+
29
+ As there are over 6500 shows listed on EZTV, I've filtered the program to parse only the Top 500 show, as ranked by IMDb. You can easily change this in the `./lib/eztv-scraper/ui.rb` file, by changing the loop to the number of shows you want. If you want the app to parse the entire site, you need to change `500` to `all_shows` and un-comment when we declare `all_shows`
30
+
31
+ ![List of Options](https://imgur.com/MHlgxy1.png)![Showlist](https://imgur.com/qfPEPb7.png)
32
+
33
+ The app goes through a sequence of methods to grab parse a new page, look for episodes, and downloads them into a file.
34
+
35
+ ![Downloading](https://imgur.com/IMB9mgL.png)
36
+
37
+ Here's how a JSON file looks like of the scraped page. The first item is a hash of details on the show, and every following item is a hash of every available episode.
38
+
39
+ ![JSON](https://imgur.com/G99jav0.png)
40
+
41
+
42
+
43
+ ## Built With
44
+
45
+ - [Ruby](https://www.ruby-lang.org/en/)
46
+ - [httparty](https://github.com/jnunemaker/httparty)
47
+ - [nokogiri](https://nokogiri.org/)
48
+ - [nikkou](https://github.com/tombenner/nikkou)
49
+ - [tty](https://ttytoolkit.org)
50
+ - [io/console](https://github.com/ruby/io-console)
51
+ - [json](https://rubygems.org/gems/json/versions/1.8.3)
52
+ - [byebug](https://github.com/deivid-rodriguez/byebug)
53
+ - [rspec](https://github.com/rspec/rspec)
54
+ - [vcr](https://github.com/vcr/vcr)
55
+
56
+
57
+ ## Getting Started
58
+
59
+
60
+ ### Prerequisites
61
+ You will need **Ruby 2.5** or above.
62
+ Visit https://www.ruby-lang.org/en/downloads/ to get your copy.
63
+
64
+ ### Setup
65
+ Clone this repo onto your local machine. Make sure you have [git](https://git-scm.com/) installed or use [GiHub Desktop](https://desktop.github.com/).
66
+ ```
67
+ $ git clone https://github.com/simonpeterdebbarma/eztv-scraper.git
68
+ ```
69
+
70
+ ### Install
71
+ This command will install all necessary gems into your system to run this app.
72
+ ```
73
+ $ bundle install
74
+ ```
75
+
76
+ ### Usage/Deployment
77
+ In your terminal, run this command.
78
+ ```
79
+ $ ruby bin/eztv-scraper.rb
80
+ ```
81
+ ### Run tests
82
+ ```
83
+ $ gem install rspec
84
+ $ rspec
85
+ ```
86
+
87
+ ## Authors
88
+
89
+ 👤 **Simon Peter Debbarma**
90
+
91
+ - Github: [@simonpeterdebbarma](https://github.com/simonpeterdebbarma)
92
+ - Twitter: [@SimonLikelySaid](https://twitter.com/SimonLikelySaid)
93
+ - Linkedin: [Simon](https://www.linkedin.com/in/simon-peter-debbarma/)
94
+
95
+ ## 🤝 Contributing
96
+
97
+ Contributions, issues and feature requests are welcome!
98
+
99
+ Feel free to check the [issues page](issues/).
100
+
101
+ ## Show your support
102
+
103
+ Give a ⭐️ if you like this project!
104
+
105
+ ## Acknowledgments
106
+
107
+ - [Microverse](https://www.microverse.org/)
108
+
109
+ ## 📝 License
110
+
111
+ This project is [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) licensed.
112
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/eztv_scraper'
4
+
5
+ EZTVScraper.new
@@ -0,0 +1,28 @@
1
+ require 'nokogiri'
2
+ require 'httparty'
3
+ require 'byebug'
4
+ require 'json'
5
+ require 'tty-prompt'
6
+ require 'nikkou'
7
+ require 'tty-progressbar'
8
+ require 'pastel'
9
+ require 'tty-spinner'
10
+ require 'tty-font'
11
+ require 'io/console'
12
+
13
+ require_relative './eztv_scraper/user_interface'
14
+ require_relative './eztv_scraper/parser'
15
+ require_relative './eztv_scraper/showlist'
16
+ require_relative './eztv_scraper/output'
17
+
18
+ class EZTVScraper
19
+ include UserInterface
20
+ include Parser
21
+ include Showlist
22
+ include Output
23
+
24
+ def initialize
25
+ @pastel = Pastel.new
26
+ welcome
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ class EZTVScraper
2
+ module Output
3
+ def json_output
4
+ puts
5
+ spinner = TTY::Spinner.new('[:spinner] Writing to /eztv-scraped', format: :dots, success_mark: '+')
6
+ spinner.auto_spin
7
+ magnets = JSON.pretty_generate(@output)
8
+ page_title = @parsed_page.css('td.section_post_header span').text.gsub(/\W/, '')
9
+ Dir.mkdir('./eztv-scraped') unless Dir.exist? './eztv-scraped'
10
+ local_fname = './eztv-scraped/' + page_title + '.json'
11
+ local_file = File.open(local_fname, 'w')
12
+ local_file.write(magnets)
13
+ local_file.close
14
+ spinner.success(@pastel.blue('(✔)'))
15
+ spinner.error(@pastel.red('(✖)'))
16
+ puts
17
+ puts ' All Tasks Completed Successfully!'
18
+ puts
19
+ puts ' ---'
20
+ puts
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ class EZTVScraper
2
+ module Parser
3
+ def list_parser
4
+ puts
5
+ spinner = TTY::Spinner.new('[:spinner] Parsing EZTV', format: :dots, success_mark: '+')
6
+ spinner.auto_spin
7
+ @eztvurl = 'https://eztv.io/showlist/rating/'
8
+ unparsed_showlist = HTTParty.get(@eztvurl)
9
+ @parsed_showlist = Nokogiri::HTML(unparsed_showlist.body)
10
+ spinner.success(@pastel.blue('(✔)'))
11
+ spinner.error(@pastel.red('(✖)'))
12
+ puts
13
+ end
14
+
15
+ def parsed_show
16
+ spinner = TTY::Spinner.new('[:spinner] Looking for episodes', format: :dots, success_mark: '+')
17
+ spinner.auto_spin
18
+ @showurl = @series_link
19
+ unparsed_page = HTTParty.get(@showurl)
20
+ @parsed_page = Nokogiri::HTML(unparsed_page.body)
21
+ spinner.success(@pastel.blue('(✔)'))
22
+ spinner.error(@pastel.red('(✖ Something went wrong)'))
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,56 @@
1
+ class EZTVScraper
2
+ module Showlist
3
+ def showlist
4
+ list_parser
5
+ @shows = []
6
+ complete = @pastel.on_green(' ')
7
+ incomplete = @pastel.on_red(' ')
8
+ # all_shows = @output.css('td.forum_thread_post').count / 3
9
+ bar = TTY::ProgressBar.new('Grabbing your favorite shows [:bar]', total: 500, width: 50, complete: complete, incomplete: incomplete)
10
+ 500.times do |n|
11
+ @shows << @parsed_showlist.css('td.forum_thread_post')[n * 3].text
12
+ bar.advance(1)
13
+ end
14
+ puts
15
+ show_prompt
16
+ end
17
+
18
+ def show_info
19
+ parsed_show
20
+ puts
21
+ spinner = TTY::Spinner.new('[:spinner] Grabbing show details', format: :dots, success_mark: '+')
22
+ spinner.auto_spin
23
+ @output = []
24
+ show_info = {
25
+ title: @parsed_page.css('td.section_post_header span')&.text,
26
+ description: @parsed_page.css('td.show_info_banner_logo p')&.text,
27
+ poster: '' + @parsed_page.css('td.show_info_main_logo').children.css('img')&.attribute('src')&.value,
28
+ imdb_rating: @parsed_page.css('td.show_info_rating_score div')[1].css('b span')&.text
29
+ }
30
+ @output << show_info
31
+ spinner.success(@pastel.blue('(✔)'))
32
+ spinner.error(@pastel.red('(✖)'))
33
+ end
34
+
35
+ def episodes_info
36
+ spinner = TTY::Spinner.new('[:spinner] Pulling magnets', format: :dots, success_mark: '+')
37
+ spinner.auto_spin
38
+ episodes = @parsed_page.css('tr.forum_header_border')
39
+ episodes.size.times do |n|
40
+ thread_posts = episodes[n].css('td.forum_thread_post')
41
+ ep = {
42
+ episode_name: thread_posts[1].css('a')&.text,
43
+ magnet: thread_posts[2].css('a').first&.attribute('href')&.value.to_s,
44
+ size: thread_posts[3]&.text,
45
+ released: thread_posts[4]&.text,
46
+ seeds: episodes[n].css('td.forum_thread_post_end')&.text
47
+ }
48
+ @output << ep
49
+ end
50
+ spinner.success(@pastel.blue('(✔)'))
51
+ spinner.error(@pastel.red('(✖)'))
52
+ json_output
53
+ choice_search
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,68 @@
1
+ class EZTVScraper
2
+ module UserInterface
3
+ def welcome
4
+ titlefont = TTY::Font.new(:starwars)
5
+ subtitlefont = TTY::Font.new(:straight)
6
+ puts @pastel.blue(titlefont.write(' EZTV'))
7
+ puts @pastel.blue(titlefont.write(' Scraper'))
8
+ puts @pastel.blue(titlefont.write(' v0.1.5'))
9
+ sleep(2)
10
+ puts @pastel.red(subtitlefont.write(' Fork me on GitHub'))
11
+ puts @pastel.yellow(' https://github.com/simonpeterdebbarma/eztv-scraper')
12
+ eztv_scrapper_info
13
+ continue_seq
14
+ showlist
15
+ end
16
+
17
+ def show_prompt
18
+ @prompt = TTY::Prompt.new
19
+ show = @prompt.select(@pastel.magenta('Select a TV show?' + @pastel.red(' (Filter only accepts 1 word)')), @shows, filter: true, per_page: 20, keys: [:return])
20
+ @series_link = 'https://eztv.io' + @parsed_showlist.search('a').text_includes(show).attribute('href').value
21
+ puts
22
+ puts ' Fantastic Choice!'
23
+ puts
24
+ show_info
25
+ puts
26
+ episodes_info
27
+ end
28
+
29
+ def eztv_scrapper_info
30
+ puts
31
+ puts ' EZTV Scraper parses https://eztv.io and helps you download'
32
+ puts ' the magnets of all available episodes into a JSON file.'
33
+ puts
34
+ puts ' As there are over 6500+ shows on the website, parsing them can'
35
+ puts ' take a lot of time. To save time when using this project,'
36
+ puts ' you are limited to only the Top 500 Shows of All Time (IMDb).'
37
+ puts ' Check the README for instructions on changing the parameter.'
38
+ puts
39
+ puts @pastel.red(' It may take about 3 minutes to parse all the data.')
40
+ puts
41
+ puts ' How about a bit of exurb1a in the meantime?'
42
+ puts @pastel.blue(' https://www.youtube.com/watch?v=V_Ac-SVYI48')
43
+ end
44
+
45
+ def choice_search
46
+ choice = @prompt.yes?(' Would you like download another series?')
47
+ if choice
48
+ puts
49
+ show_prompt
50
+ else
51
+ goodbye
52
+ end
53
+ end
54
+
55
+ def goodbye
56
+ puts
57
+ puts @pastel.green(' ~ Thank you for using eztv-scraper! ~')
58
+ puts @pastel.green(' ~ Star this project on Github if you liked it ~')
59
+ end
60
+
61
+ def continue_seq
62
+ puts
63
+ print ' Press any key to continue...'
64
+ STDIN.getch
65
+ puts "\n"
66
+ end
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eztv_scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Simon Peter Debbarma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.17.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.17.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: nikkou
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.10.8
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.10.8
69
+ - !ruby/object:Gem::Dependency
70
+ name: pastel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.3
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-font
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-progressbar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.17.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.17.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: tty-prompt
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.20.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.20.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: tty-spinner
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.9.3
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.9.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 3.9.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 3.9.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 11.1.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 11.1.1
167
+ description:
168
+ email:
169
+ executables:
170
+ - eztv_scraper
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - Gemfile
175
+ - README.md
176
+ - bin/eztv_scraper
177
+ - lib/eztv_scraper.rb
178
+ - lib/eztv_scraper/output.rb
179
+ - lib/eztv_scraper/parser.rb
180
+ - lib/eztv_scraper/showlist.rb
181
+ - lib/eztv_scraper/user_interface.rb
182
+ homepage:
183
+ licenses:
184
+ - GPL-3.0
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubygems_version: 3.0.3
202
+ signing_key:
203
+ specification_version: 4
204
+ summary: eztv_scraper looks for any selected show on eztv.io and saves magnet links
205
+ of every single available episode into a JSON file.
206
+ test_files: []