imdb-terminal 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/imdb +41 -14
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b26870720d0e55ae88bc797de5e902b24bca1deac0514c3c29058b90df31d08
|
|
4
|
+
data.tar.gz: 39c9433b18a602fa2f7b16493ae94841896da14493b24256852c1bd70253a403
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92396d67a67433e37f25fa135577f012f1259c88e7cc859f868eec153705a35cd138fb57aeb26132927d82b502d3ebf40dab9ae0ee6999a6fb0e951b71a2ed0c
|
|
7
|
+
data.tar.gz: 556c17abd3c6e6b2b5aaebb6a5b1e179cb16374f82945ce2fa484185bebfb9eaf0a2329d892a9ed0cd3ee12987a22536e6dba767034a241feee07eda0d9af66f
|
data/bin/imdb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# for any damages resulting from its use. Further, I am under no
|
|
15
15
|
# obligation to maintain or extend this software. It is provided
|
|
16
16
|
# on an 'as is' basis without any expressed or implied warranty.
|
|
17
|
-
# Version: 2.1.
|
|
17
|
+
# Version: 2.1.1: Add HTTP timeouts and external command error handling
|
|
18
18
|
|
|
19
19
|
# REQUIRES AND CONSTANTS {{{1
|
|
20
20
|
require 'io/console'
|
|
@@ -411,7 +411,8 @@ class IMDBApp
|
|
|
411
411
|
uri = "https://www.imdb.com/#{path}/"
|
|
412
412
|
|
|
413
413
|
begin
|
|
414
|
-
raw = `curl -sfL -H "User-Agent: #{ua}" "#{uri}"`
|
|
414
|
+
raw = `curl -sfL --max-time 15 --connect-timeout 10 -H "User-Agent: #{ua}" "#{uri}"`
|
|
415
|
+
return [] unless $?.success?
|
|
415
416
|
html = raw.force_encoding('UTF-8').scrub('')
|
|
416
417
|
doc = Nokogiri::HTML(html)
|
|
417
418
|
|
|
@@ -454,10 +455,19 @@ class IMDBApp
|
|
|
454
455
|
|
|
455
456
|
def scrape_json_ld(path, ua) #{{{2
|
|
456
457
|
uri = "https://www.imdb.com/#{path}/"
|
|
457
|
-
|
|
458
|
+
begin
|
|
459
|
+
raw = `curl -sfL --max-time 15 --connect-timeout 10 -H "User-Agent: #{ua}" "#{uri}"`
|
|
460
|
+
unless $?.success?
|
|
461
|
+
@progress.say("Warning: Failed to fetch #{path}") if defined?(@progress) && @progress
|
|
462
|
+
return []
|
|
463
|
+
end
|
|
464
|
+
rescue => e
|
|
465
|
+
@progress.say("Warning: curl error for #{path}: #{e.message}") if defined?(@progress) && @progress
|
|
466
|
+
return []
|
|
467
|
+
end
|
|
458
468
|
html = raw.force_encoding('UTF-8').scrub('')
|
|
459
469
|
doc = Nokogiri::HTML(html)
|
|
460
|
-
|
|
470
|
+
|
|
461
471
|
if (ld = doc.at_css('script[type="application/ld+json"]'))
|
|
462
472
|
begin
|
|
463
473
|
data = JSON.parse(ld.text)
|
|
@@ -475,7 +485,7 @@ class IMDBApp
|
|
|
475
485
|
# fall back to HTML scrape
|
|
476
486
|
end
|
|
477
487
|
end
|
|
478
|
-
|
|
488
|
+
|
|
479
489
|
doc.css('.lister-list tr').map do |tr|
|
|
480
490
|
rating = tr.at_css('td.ratingColumn strong')&.text.to_f || 0.0
|
|
481
491
|
a = tr.at_css('td.titleColumn a') or next
|
|
@@ -769,16 +779,27 @@ class IMDBApp
|
|
|
769
779
|
def download_poster(tconst, cache) #{{{2
|
|
770
780
|
url = fetch_imdb_poster_url(tconst)
|
|
771
781
|
return unless url
|
|
772
|
-
|
|
782
|
+
|
|
773
783
|
dest = File.join(cache, "#{tconst}.jpg")
|
|
774
784
|
return if File.exist?(dest) && File.size(dest) > 1000
|
|
775
|
-
|
|
785
|
+
|
|
776
786
|
cmd = [
|
|
777
|
-
'curl', '-sfL', '--max-time', '10', '--
|
|
787
|
+
'curl', '-sfL', '--max-time', '10', '--connect-timeout', '10',
|
|
788
|
+
'--retry', '2', '--retry-delay', '1',
|
|
778
789
|
'-H', 'User-Agent: Mozilla/5.0', '-o', dest, url
|
|
779
790
|
].map { |arg| Shellwords.escape(arg) }.join(' ')
|
|
780
|
-
|
|
781
|
-
|
|
791
|
+
|
|
792
|
+
begin
|
|
793
|
+
system(cmd, err: File::NULL)
|
|
794
|
+
# Remove incomplete downloads
|
|
795
|
+
if File.exist?(dest) && File.size(dest) < 100
|
|
796
|
+
File.delete(dest) rescue nil
|
|
797
|
+
end
|
|
798
|
+
rescue => e
|
|
799
|
+
File.open("/tmp/imdb_fetch_errors.log", "a") do |f|
|
|
800
|
+
f.puts "[#{Time.now.iso8601}] Poster download failed for #{tconst}: #{e.message}"
|
|
801
|
+
end
|
|
802
|
+
end
|
|
782
803
|
end
|
|
783
804
|
|
|
784
805
|
def fetch_imdb_poster_url(tconst) #{{{2
|
|
@@ -786,9 +807,13 @@ class IMDBApp
|
|
|
786
807
|
html = URI.open(
|
|
787
808
|
"https://www.imdb.com/title/#{tconst}/",
|
|
788
809
|
"User-Agent" => "Mozilla/5.0",
|
|
789
|
-
"Accept-Encoding" => "identity"
|
|
810
|
+
"Accept-Encoding" => "identity",
|
|
811
|
+
open_timeout: 10,
|
|
812
|
+
read_timeout: 10
|
|
790
813
|
).read
|
|
791
|
-
rescue SocketError, Errno::ECONNREFUSED, OpenURI::HTTPError,
|
|
814
|
+
rescue SocketError, Errno::ECONNREFUSED, OpenURI::HTTPError,
|
|
815
|
+
Net::HTTPBadResponse, Net::OpenTimeout, Net::ReadTimeout,
|
|
816
|
+
Timeout::Error, Errno::ETIMEDOUT
|
|
792
817
|
return nil
|
|
793
818
|
end
|
|
794
819
|
html[/<meta property="og:image" content="([^"]+)"/,1]
|
|
@@ -1190,12 +1215,14 @@ class IMDBApp
|
|
|
1190
1215
|
uri.query = URI.encode_www_form(q: query, s: 'tt')
|
|
1191
1216
|
html = nil
|
|
1192
1217
|
begin
|
|
1193
|
-
Timeout.timeout(
|
|
1218
|
+
Timeout.timeout(15) do
|
|
1194
1219
|
html = URI.open(uri.to_s,
|
|
1195
1220
|
'User-Agent' => 'Mozilla/5.0',
|
|
1196
1221
|
'Accept' => 'text/html,application/xhtml+xml',
|
|
1197
1222
|
'Accept-Language' => 'en-US,en;q=0.9',
|
|
1198
|
-
'Accept-Encoding' => 'identity'
|
|
1223
|
+
'Accept-Encoding' => 'identity',
|
|
1224
|
+
open_timeout: 10,
|
|
1225
|
+
read_timeout: 10
|
|
1199
1226
|
).read
|
|
1200
1227
|
# Fix encoding issues
|
|
1201
1228
|
html = html.force_encoding('UTF-8').scrub('?')
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: imdb-terminal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rcurses
|
|
@@ -80,11 +80,12 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '13.0'
|
|
83
|
-
description: 'IMDB v2.1.
|
|
83
|
+
description: 'IMDB v2.1.1: Modern poster display using termpix gem with Sixel and
|
|
84
84
|
w3m protocol support. Discover and manage movies and TV series from IMDb''s Top
|
|
85
85
|
250 lists. Features smart search with preview mode, advanced filtering by rating/year/genre,
|
|
86
86
|
streaming information via TMDb, wish lists, and terminal poster display. Enhanced
|
|
87
|
-
with jump-to-existing items, duplicate management,
|
|
87
|
+
with jump-to-existing items, duplicate management, robust data handling, and improved
|
|
88
|
+
HTTP timeout/error handling.'
|
|
88
89
|
email: g@isene.com
|
|
89
90
|
executables:
|
|
90
91
|
- imdb
|