gamerom 0.4.0 → 0.5.0
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/.github/workflows/main.yml +3 -3
- data/.rubocop.yml +4 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +18 -1
- data/Dockerfile +13 -3
- data/Gemfile +5 -3
- data/Gemfile.lock +85 -61
- data/Makefile +4 -4
- data/README.md +15 -50
- data/entrypoint.sh +1 -0
- data/exe/gamerom +16 -0
- data/gamerom.gemspec +8 -7
- data/lib/gamerom/cli.rb +13 -11
- data/lib/gamerom/game.rb +10 -2
- data/lib/gamerom/game_info.rb +1 -1
- data/lib/gamerom/repo.rb +2 -2
- data/lib/gamerom/repo_adapter.rb +10 -3
- data/lib/gamerom/repo_adapters/coolrom.rb +5 -2
- data/lib/gamerom/repo_adapters/vimm.rb +16 -1
- data/lib/gamerom/version.rb +1 -1
- data/lib/mechanizeprogress.rb +33 -2
- metadata +14 -16
- data/lib/gamerom/repo_adapters/romnation.rb +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65b18f9a39d07cc281d8409b6a4ac6992980f450af58aef33e91148ae17c480b
|
4
|
+
data.tar.gz: 258c224ac84dafe08ae695c1dae35a7ecb7448e331c8a34cd78685c688e8e59a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b999f0ee86796dee15f20593cbad36a27051798e01213e64676b004c77452ffe1d5a986d3c50cdcd8bafc09871ccee9278e371ed059d608951fa52a9c864f2b8
|
7
|
+
data.tar.gz: c1a4433b96a14883f8114eb23687826365c2f2df850d2dc0a686d1e1b01753f1875fda3d790cae458d0def27dceaf9ad28fa901a75c28b0b8fba8a97251fb917
|
data/.github/workflows/main.yml
CHANGED
@@ -6,13 +6,13 @@ jobs:
|
|
6
6
|
build:
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
steps:
|
9
|
-
- uses: actions/checkout@
|
9
|
+
- uses: actions/checkout@v4
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version: 3.
|
13
|
+
ruby-version: 3.4.2
|
14
14
|
- name: Run the default task
|
15
15
|
run: |
|
16
|
-
gem install bundler -v 2.2
|
16
|
+
gem install bundler -v 2.6.2
|
17
17
|
bundle install
|
18
18
|
bundle exec rake
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.4.2
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.4.2
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.5.0] - 2025-03-25
|
10
|
+
- feat: add ps3 platform for coolrom repo
|
11
|
+
- feat: add new platforms for vimm repo (Sega 32X, Atari 2600, Atari 5200, Atari 7800, Game Gear, Lynx, Sega CD, Master System, TurboGrafx-16, TurboGrafx-CD, Virtual Boy, XBox, XBox 360)
|
12
|
+
- feat: remove deprecated romnation repo
|
13
|
+
- feat: use ruby 3.4.2 and update all dependencies
|
14
|
+
- feat: format progress bars (colored pacman style)
|
15
|
+
- feat: handle SIGINT and SIGTERM
|
16
|
+
- fix: vimm repo game install
|
17
|
+
- fix: coolrom repo broken progress
|
18
|
+
- fix: vimm repo unable to get local issuer
|
19
|
+
- fix: vimm repo update datase (404 not found)
|
20
|
+
|
21
|
+
## [0.4.1] - 2021-05-18
|
22
|
+
- Enables specifying game identifier without using quotes
|
23
|
+
|
9
24
|
## [0.4.0] - 2021-05-18
|
10
25
|
- Refactor code #2
|
11
26
|
- Fix all rubocop errors/warnings
|
@@ -31,7 +46,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
31
46
|
## [0.1.0] - 2021-05-07
|
32
47
|
- Initial release
|
33
48
|
|
34
|
-
[Unreleased]: https://github.com/lucasmundim/gamerom/compare/v0.
|
49
|
+
[Unreleased]: https://github.com/lucasmundim/gamerom/compare/v0.5.0...HEAD
|
50
|
+
[0.5.0]: https://github.com/lucasmundim/gamerom/compare/v0.4.1...v0.5.0
|
51
|
+
[0.4.1]: https://github.com/lucasmundim/gamerom/compare/v0.4.0...v0.4.1
|
35
52
|
[0.4.0]: https://github.com/lucasmundim/gamerom/compare/v0.3.0...v0.4.0
|
36
53
|
[0.3.0]: https://github.com/lucasmundim/gamerom/compare/v0.2.2...v0.3.0
|
37
54
|
[0.2.2]: https://github.com/lucasmundim/gamerom/compare/v0.2.1...v0.2.2
|
data/Dockerfile
CHANGED
@@ -1,16 +1,26 @@
|
|
1
|
-
FROM ruby:3.
|
1
|
+
FROM ruby:3.4.2-alpine
|
2
2
|
|
3
3
|
RUN apk add --no-cache --virtual .build-deps \
|
4
4
|
build-base \
|
5
|
+
ca-certificates \
|
6
|
+
curl \
|
5
7
|
git
|
6
8
|
|
7
9
|
# throw errors if Gemfile has been modified since Gemfile.lock
|
8
10
|
RUN bundle config --global frozen 1
|
9
11
|
|
12
|
+
# Add missing certificates
|
13
|
+
RUN curl -s https://letsencrypt.org/certs/2024/e5.pem -o /etc/ssl/certs/e5.pem && \
|
14
|
+
curl -s https://letsencrypt.org/certs/2024/e5.pem -o /etc/ssl/certs/e5.pem && \
|
15
|
+
curl -s https://letsencrypt.org/certs/2024/e6.pem -o /etc/ssl/certs/e6.pem && \
|
16
|
+
curl -s https://letsencrypt.org/certs/2024/r10.pem -o /etc/ssl/certs/r10.pem && \
|
17
|
+
curl -s https://letsencrypt.org/certs/2024/r11.pem -o /etc/ssl/certs/r11.pem && \
|
18
|
+
update-ca-certificates
|
19
|
+
|
10
20
|
RUN mkdir -p /bundle && chmod 777 /bundle
|
11
21
|
|
12
22
|
ENV GEM_HOME="/bundle"
|
13
|
-
ENV PATH
|
23
|
+
ENV PATH=$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
|
14
24
|
|
15
25
|
RUN mkdir -p /app
|
16
26
|
WORKDIR /app
|
@@ -18,4 +28,4 @@ WORKDIR /app
|
|
18
28
|
COPY . .
|
19
29
|
RUN bundle install
|
20
30
|
|
21
|
-
ENTRYPOINT ["/app/entrypoint.sh"]
|
31
|
+
ENTRYPOINT ["/app/entrypoint.sh"]
|
data/Gemfile
CHANGED
@@ -5,8 +5,10 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in gamerom.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem 'rake', '~> 13.
|
8
|
+
gem 'rake', '~> 13.2.1'
|
9
9
|
|
10
|
-
gem 'rspec', '~> 3.0'
|
10
|
+
gem 'rspec', '~> 3.13.0'
|
11
11
|
|
12
|
-
gem 'rubocop', '~> 0
|
12
|
+
gem 'rubocop', '~> 1.74.0'
|
13
|
+
gem 'rubocop-rake', '~> 0.7.1'
|
14
|
+
gem 'rubocop-rspec', '~> 3.5.0'
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gamerom (0.
|
5
|
-
mechanize (~> 2.
|
4
|
+
gamerom (0.5.0)
|
5
|
+
mechanize (~> 2.14.0)
|
6
6
|
mechanize-progressbar (~> 0.2.0)
|
7
|
-
nokogiri (~> 1.
|
8
|
-
progressbar (~>
|
7
|
+
nokogiri (~> 1.18.5)
|
8
|
+
progressbar (~> 1.13.0)
|
9
9
|
rest-client (~> 2.1.0)
|
10
|
-
thor (~> 1.
|
10
|
+
thor (~> 1.3.2)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
addressable (2.7
|
16
|
-
public_suffix (>= 2.0.2, <
|
17
|
-
ast (2.4.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
addressable (2.8.7)
|
16
|
+
public_suffix (>= 2.0.2, < 7.0)
|
17
|
+
ast (2.4.3)
|
18
|
+
base64 (0.2.0)
|
19
|
+
connection_pool (2.5.0)
|
20
|
+
diff-lcs (1.6.0)
|
21
|
+
domain_name (0.6.20240107)
|
22
22
|
http-accept (1.7.0)
|
23
|
-
http-cookie (1.0.
|
23
|
+
http-cookie (1.0.8)
|
24
24
|
domain_name (~> 0.5)
|
25
|
-
|
26
|
-
|
25
|
+
json (2.10.2)
|
26
|
+
language_server-protocol (3.17.0.4)
|
27
|
+
lint_roller (1.1.0)
|
28
|
+
logger (1.6.6)
|
29
|
+
mechanize (2.14.0)
|
30
|
+
addressable (~> 2.8)
|
31
|
+
base64
|
27
32
|
domain_name (~> 0.5, >= 0.5.20190701)
|
28
33
|
http-cookie (~> 1.0, >= 1.0.3)
|
29
|
-
mime-types (~> 3.
|
34
|
+
mime-types (~> 3.3)
|
30
35
|
net-http-digest_auth (~> 1.4, >= 1.4.1)
|
31
36
|
net-http-persistent (>= 2.5.2, < 5.0.dev)
|
37
|
+
nkf
|
32
38
|
nokogiri (~> 1.11, >= 1.11.2)
|
33
39
|
rubyntlm (~> 0.6, >= 0.6.3)
|
34
40
|
webrick (~> 1.7)
|
@@ -36,75 +42,93 @@ GEM
|
|
36
42
|
mechanize-progressbar (0.2.0)
|
37
43
|
mechanize (>= 1.0.0)
|
38
44
|
progressbar (>= 0.9.0)
|
39
|
-
mime-types (3.
|
45
|
+
mime-types (3.6.1)
|
46
|
+
logger
|
40
47
|
mime-types-data (~> 3.2015)
|
41
|
-
mime-types-data (3.
|
48
|
+
mime-types-data (3.2025.0318)
|
42
49
|
net-http-digest_auth (1.4.1)
|
43
|
-
net-http-persistent (4.0.
|
50
|
+
net-http-persistent (4.0.5)
|
44
51
|
connection_pool (~> 2.2)
|
45
52
|
netrc (0.11.0)
|
46
|
-
|
53
|
+
nkf (0.2.0)
|
54
|
+
nokogiri (1.18.5-aarch64-linux-musl)
|
47
55
|
racc (~> 1.4)
|
48
|
-
nokogiri (1.
|
56
|
+
nokogiri (1.18.5-arm64-darwin)
|
49
57
|
racc (~> 1.4)
|
50
|
-
|
51
|
-
|
58
|
+
nokogiri (1.18.5-x86_64-darwin)
|
59
|
+
racc (~> 1.4)
|
60
|
+
nokogiri (1.18.5-x86_64-linux-musl)
|
61
|
+
racc (~> 1.4)
|
62
|
+
parallel (1.26.3)
|
63
|
+
parser (3.3.7.2)
|
52
64
|
ast (~> 2.4.1)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
65
|
+
racc
|
66
|
+
progressbar (1.13.0)
|
67
|
+
public_suffix (6.0.1)
|
68
|
+
racc (1.8.1)
|
69
|
+
rainbow (3.1.1)
|
70
|
+
rake (13.2.1)
|
71
|
+
regexp_parser (2.10.0)
|
59
72
|
rest-client (2.1.0)
|
60
73
|
http-accept (>= 1.7.0, < 2.0)
|
61
74
|
http-cookie (>= 1.0.2, < 2.0)
|
62
75
|
mime-types (>= 1.16, < 4.0)
|
63
76
|
netrc (~> 0.8)
|
64
|
-
|
65
|
-
|
66
|
-
rspec-
|
67
|
-
rspec-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rspec-expectations (3.10.1)
|
77
|
+
rspec (3.13.0)
|
78
|
+
rspec-core (~> 3.13.0)
|
79
|
+
rspec-expectations (~> 3.13.0)
|
80
|
+
rspec-mocks (~> 3.13.0)
|
81
|
+
rspec-core (3.13.3)
|
82
|
+
rspec-support (~> 3.13.0)
|
83
|
+
rspec-expectations (3.13.3)
|
72
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-mocks (3.
|
85
|
+
rspec-support (~> 3.13.0)
|
86
|
+
rspec-mocks (3.13.2)
|
75
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-support (3.
|
78
|
-
rubocop (
|
88
|
+
rspec-support (~> 3.13.0)
|
89
|
+
rspec-support (3.13.2)
|
90
|
+
rubocop (1.74.0)
|
91
|
+
json (~> 2.3)
|
92
|
+
language_server-protocol (~> 3.17.0.2)
|
93
|
+
lint_roller (~> 1.1.0)
|
79
94
|
parallel (~> 1.10)
|
80
|
-
parser (>=
|
95
|
+
parser (>= 3.3.0.2)
|
81
96
|
rainbow (>= 2.2.2, < 4.0)
|
82
|
-
regexp_parser (>=
|
83
|
-
|
84
|
-
rubocop-ast (>= 0.6.0)
|
97
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
98
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
85
99
|
ruby-progressbar (~> 1.7)
|
86
|
-
unicode-display_width (>=
|
87
|
-
rubocop-ast (1.
|
88
|
-
parser (>=
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
100
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
101
|
+
rubocop-ast (1.41.0)
|
102
|
+
parser (>= 3.3.7.2)
|
103
|
+
rubocop-rake (0.7.1)
|
104
|
+
lint_roller (~> 1.1)
|
105
|
+
rubocop (>= 1.72.1)
|
106
|
+
rubocop-rspec (3.5.0)
|
107
|
+
lint_roller (~> 1.1)
|
108
|
+
rubocop (~> 1.72, >= 1.72.1)
|
109
|
+
ruby-progressbar (1.13.0)
|
110
|
+
rubyntlm (0.6.5)
|
111
|
+
base64
|
112
|
+
thor (1.3.2)
|
113
|
+
unicode-display_width (3.1.4)
|
114
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
115
|
+
unicode-emoji (4.0.4)
|
116
|
+
webrick (1.9.1)
|
97
117
|
webrobots (0.1.2)
|
98
118
|
|
99
119
|
PLATFORMS
|
120
|
+
aarch64-linux-musl
|
121
|
+
arm64-darwin-24
|
100
122
|
x86_64-darwin-20
|
101
123
|
x86_64-linux-musl
|
102
124
|
|
103
125
|
DEPENDENCIES
|
104
126
|
gamerom!
|
105
|
-
rake (~> 13.
|
106
|
-
rspec (~> 3.0)
|
107
|
-
rubocop (~> 0
|
127
|
+
rake (~> 13.2.1)
|
128
|
+
rspec (~> 3.13.0)
|
129
|
+
rubocop (~> 1.74.0)
|
130
|
+
rubocop-rake (~> 0.7.1)
|
131
|
+
rubocop-rspec (~> 3.5.0)
|
108
132
|
|
109
133
|
BUNDLED WITH
|
110
|
-
2.2
|
134
|
+
2.6.2
|
data/Makefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
VERSION
|
2
|
-
IMAGE
|
3
|
-
DOCKER_OPTS
|
1
|
+
VERSION?=$(shell cat lib/gamerom/version.rb |grep VERSION|cut -d\' -f2)
|
2
|
+
IMAGE?=lucasmundim/gamerom:${VERSION}
|
3
|
+
DOCKER_OPTS=-e UID=$(shell id -u) -e GROUP_ID=$(shell id -g) --rm -it -v ${HOME}/.gamerom:/root/.gamerom --platform=linux/amd64 ${IMAGE}
|
4
4
|
LOCAL_VOLUME_OPTS=-v ${CURDIR}:/app
|
5
5
|
DOCKER_DEVELOPMENT_OPTS=${LOCAL_VOLUME_OPTS} --entrypoint '' ${DOCKER_OPTS}
|
6
6
|
|
@@ -8,7 +8,7 @@ version:
|
|
8
8
|
@echo ${VERSION}
|
9
9
|
|
10
10
|
build:
|
11
|
-
@docker build -t ${IMAGE} .
|
11
|
+
@docker build --platform=linux/amd64 -t ${IMAGE} .
|
12
12
|
|
13
13
|
console:
|
14
14
|
@docker run ${DOCKER_DEVELOPMENT_OPTS} ./bin/console
|
data/README.md
CHANGED
@@ -6,7 +6,6 @@ It currently supports the following repositories:
|
|
6
6
|
|
7
7
|
- https://vimm.net
|
8
8
|
- https://coolrom.com.au
|
9
|
-
- https://www.romnation.net
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
|
@@ -15,7 +14,7 @@ It currently supports the following repositories:
|
|
15
14
|
Add this to your .bashrc, .bash_aliases, etc:
|
16
15
|
|
17
16
|
```
|
18
|
-
alias gamerom="docker run -e UID=$(id -u) -e GROUP_ID=$(id -g) --rm -it -v ~/.gamerom:/home/runuser/.gamerom docker.io/lucasmundim/gamerom:0.
|
17
|
+
alias gamerom="docker run -e UID=$(id -u) -e GROUP_ID=$(id -g) --rm -it -v ~/.gamerom:/home/runuser/.gamerom --platform=linux/amd64 docker.io/lucasmundim/gamerom:0.5.0"
|
19
18
|
```
|
20
19
|
|
21
20
|
Use it as:
|
@@ -86,7 +85,6 @@ List available repo
|
|
86
85
|
$ gamerom repo
|
87
86
|
listing available repo...
|
88
87
|
coolrom
|
89
|
-
romnation
|
90
88
|
vimm
|
91
89
|
```
|
92
90
|
|
@@ -124,46 +122,6 @@ listing available platforms for coolrom repo...
|
|
124
122
|
psp: Sony Playstation Portable
|
125
123
|
```
|
126
124
|
|
127
|
-
```
|
128
|
-
$ gamerom platforms -r romnation
|
129
|
-
listing available platforms for romnation repo...
|
130
|
-
---
|
131
|
-
:platforms:
|
132
|
-
amstrad: Amstrad
|
133
|
-
atari2600: Atari 2600
|
134
|
-
atari5200: Atari 5200
|
135
|
-
atari7800: Atari 7800
|
136
|
-
atarijaguar: Atari Jaguar
|
137
|
-
atarilynx: Atari Lynx
|
138
|
-
colecovision: ColecoVision
|
139
|
-
commodore64: Commodore 64
|
140
|
-
gamegear: Game Gear
|
141
|
-
gb: Game Boy
|
142
|
-
gbc: Game Boy Color
|
143
|
-
gcdvectrex: Vectrex
|
144
|
-
genesis: Genesis
|
145
|
-
intellivision: Intellivision
|
146
|
-
mame: MAME
|
147
|
-
msx1: MSX
|
148
|
-
msx2: MSX2
|
149
|
-
mtx: MTX
|
150
|
-
n64: N64
|
151
|
-
neogeocd: Neo Geo CD
|
152
|
-
neogeopocket: Neo Geo Pocket
|
153
|
-
nes: NES
|
154
|
-
oric: Oric
|
155
|
-
pce: PC Engine
|
156
|
-
radioshackcolorcomputer: TRS-80
|
157
|
-
samcoupe: SAM Coupé
|
158
|
-
segacd: Sega CD
|
159
|
-
segamastersystem: Master System
|
160
|
-
snes: SNES
|
161
|
-
thompsonmo5: Thomson MO5
|
162
|
-
virtualboy: Virtual Boy
|
163
|
-
watara: Watara Supervision
|
164
|
-
wonderswan: WonderSwan
|
165
|
-
```
|
166
|
-
|
167
125
|
```
|
168
126
|
$ gamerom platform -r vimm
|
169
127
|
listing available platforms for vimm repo...
|
@@ -214,12 +172,19 @@ ID NAME REGION INSTALLED TAGS
|
|
214
172
|
Search games by KEYWORD
|
215
173
|
|
216
174
|
```
|
217
|
-
$ gamerom search -r
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
175
|
+
$ gamerom search -r vimm -p segamastersystem "Alex Kidd in Shinobi World"
|
176
|
+
$ bundle exec gamerom search --repo vimm --platform SMS "Alex Kidd"
|
177
|
+
searching available games for SMS platform on vimm repo...
|
178
|
+
ID NAME REGION INSTALLED TAGS
|
179
|
+
83680 Alex Kidd in Miracle World USA - -
|
180
|
+
83681 Alex Kidd in Miracle World USA - -
|
181
|
+
83682 Alex Kidd in Miracle World (Sega Ages) USA - -
|
182
|
+
83682 Alex Kidd in Miracle World (Sega Ages) USA - -
|
183
|
+
83684 Alex Kidd in Shinobi World USA - -
|
184
|
+
83671 Alex Kidd: High-Tech World USA - -
|
185
|
+
83673 Alex Kidd: The Lost Stars USA - -
|
186
|
+
83630 [BIOS] Alex Kidd in Miracle World USA - -
|
187
|
+
83631 [BIOS] Alex Kidd in Miracle World (Sega Ages) USA - -
|
223
188
|
```
|
224
189
|
|
225
190
|
### regions
|
@@ -585,7 +550,7 @@ Print program version
|
|
585
550
|
|
586
551
|
```
|
587
552
|
$ gamerom version
|
588
|
-
0.
|
553
|
+
0.5.0
|
589
554
|
```
|
590
555
|
|
591
556
|
## Development
|
data/entrypoint.sh
CHANGED
@@ -2,5 +2,6 @@
|
|
2
2
|
delgroup dialout
|
3
3
|
addgroup -g "$GROUP_ID" rungroup
|
4
4
|
adduser -u $UID -D -s /bin/sh -G rungroup runuser
|
5
|
+
git config --system --add safe.directory '/app'
|
5
6
|
command="cd /app && GEM_HOME="/bundle" PATH=$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH bundle exec ./exe/gamerom ${@}"
|
6
7
|
su - runuser -c "$command"
|
data/exe/gamerom
CHANGED
@@ -3,4 +3,20 @@
|
|
3
3
|
|
4
4
|
require 'gamerom'
|
5
5
|
|
6
|
+
def shut_down
|
7
|
+
puts "\nShutting down gracefully..."
|
8
|
+
end
|
9
|
+
|
10
|
+
# Trap ^C
|
11
|
+
Signal.trap('INT') do
|
12
|
+
shut_down
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
# Trap `Kill `
|
17
|
+
Signal.trap('TERM') do
|
18
|
+
shut_down
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
6
22
|
Gamerom::Cli.start(ARGV)
|
data/gamerom.gemspec
CHANGED
@@ -12,13 +12,14 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'A command-line installer for game ROMs from many repositories.'
|
13
13
|
spec.homepage = 'https://github.com/lucasmundim/gamerom'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 3.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.4.2')
|
16
16
|
|
17
17
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
18
|
|
19
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
20
|
spec.metadata['source_code_uri'] = spec.homepage
|
21
21
|
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
22
23
|
|
23
24
|
# Specify which files should be added to the gem when it is released.
|
24
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -29,12 +30,12 @@ Gem::Specification.new do |spec|
|
|
29
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
31
|
spec.require_paths = ['lib']
|
31
32
|
|
32
|
-
spec.
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.
|
33
|
+
spec.add_dependency 'mechanize', '~> 2.14.0'
|
34
|
+
spec.add_dependency 'mechanize-progressbar', '~> 0.2.0'
|
35
|
+
spec.add_dependency 'nokogiri', '~> 1.18.5'
|
36
|
+
spec.add_dependency 'progressbar', '~> 1.13.0'
|
37
|
+
spec.add_dependency 'rest-client', '~> 2.1.0'
|
38
|
+
spec.add_dependency 'thor', '~> 1.3.2'
|
38
39
|
|
39
40
|
# For more information and examples about making a new gem, checkout our
|
40
41
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/gamerom/cli.rb
CHANGED
@@ -25,16 +25,17 @@ module Gamerom
|
|
25
25
|
desc 'info GAME_IDENTIFIER', 'Info for game GAME_IDENTIFIER (id/name)'
|
26
26
|
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
27
27
|
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
28
|
-
def info(
|
28
|
+
def info(*args)
|
29
|
+
game_identifier = args.join(' ')
|
29
30
|
repo = Repo.new(options[:repo])
|
30
31
|
validate_platform repo, options[:platform]
|
31
32
|
puts "showing info for game #{game_identifier} on #{options[:platform]} platform on #{options[:repo]} repo..."
|
32
33
|
game = repo.find(options[:platform], game_identifier)
|
33
|
-
if
|
34
|
+
if game.nil?
|
35
|
+
shell.say "Game #{game_identifier} not found", :red
|
36
|
+
else
|
34
37
|
puts game
|
35
38
|
puts game.filenames if game.installed?
|
36
|
-
else
|
37
|
-
shell.say "Game #{game_identifier} not found", :red
|
38
39
|
end
|
39
40
|
rescue StandardError => e
|
40
41
|
render_error e, options
|
@@ -44,7 +45,8 @@ module Gamerom
|
|
44
45
|
desc 'install GAME_IDENTIFIER', 'Install game GAME_IDENTIFIER (id/name)'
|
45
46
|
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
46
47
|
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
47
|
-
def install(
|
48
|
+
def install(*args)
|
49
|
+
game_identifier = args.join(' ')
|
48
50
|
repo = Repo.new(options[:repo])
|
49
51
|
validate_platform repo, options[:platform]
|
50
52
|
game = repo.find(options[:platform], game_identifier)
|
@@ -166,7 +168,8 @@ module Gamerom
|
|
166
168
|
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
167
169
|
option :region, aliases: ['-g'], type: :string, required: false, desc: 'Only from specified region'
|
168
170
|
option :install, aliases: ['-I'], type: :boolean, required: false, desc: 'Install search results'
|
169
|
-
def search(
|
171
|
+
def search(*args)
|
172
|
+
keyword = args.join(' ')
|
170
173
|
repo = Repo.new(options[:repo])
|
171
174
|
validate_platform repo, options[:platform]
|
172
175
|
puts "searching available games for #{options[:platform]} platform on #{options[:repo]} repo..."
|
@@ -231,7 +234,8 @@ module Gamerom
|
|
231
234
|
desc 'uninstall GAME_IDENTIFIER', 'Uninstall game GAME_IDENTIFIER (id/name)'
|
232
235
|
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
233
236
|
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
234
|
-
def uninstall(
|
237
|
+
def uninstall(*args)
|
238
|
+
game_identifier = args.join(' ')
|
235
239
|
repo = Repo.new(options[:repo])
|
236
240
|
validate_platform repo, options[:platform]
|
237
241
|
game = repo.find(options[:platform], game_identifier)
|
@@ -304,10 +308,8 @@ module Gamerom
|
|
304
308
|
private
|
305
309
|
|
306
310
|
def print_game_table(games)
|
307
|
-
results =
|
308
|
-
|
309
|
-
games.each do |game|
|
310
|
-
results << [
|
311
|
+
results = games.map do |game|
|
312
|
+
[
|
311
313
|
game.id,
|
312
314
|
game.name,
|
313
315
|
game.region,
|
data/lib/gamerom/game.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
-
require 'ostruct'
|
5
4
|
require 'yaml'
|
6
5
|
|
7
6
|
module Gamerom
|
8
7
|
# Game - Represents a game ROM
|
9
|
-
class Game
|
8
|
+
class Game
|
9
|
+
attr_accessor :id, :name, :platform, :region, :repo, :tags
|
10
|
+
|
11
|
+
def initialize(attributes = {})
|
12
|
+
@tags = []
|
13
|
+
attributes.each do |key, value|
|
14
|
+
instance_variable_set("@#{key}", value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
def filenames
|
11
19
|
YAML.load_file(state_filename).map do |filename|
|
12
20
|
"#{filepath}/#{filename}"
|
data/lib/gamerom/game_info.rb
CHANGED
@@ -84,7 +84,7 @@ module Gamerom
|
|
84
84
|
tags = []
|
85
85
|
codes = @name.scan(/\[(?<code>[^\]]+)\]/).flatten
|
86
86
|
codes.each do |code|
|
87
|
-
code = Regexp.last_match(1) if code.match
|
87
|
+
code = Regexp.last_match(1) if code.match(/^(?<code>[abcfhop])[0-9]*/)
|
88
88
|
tags << TAGS[code] if TAGS.include?(code)
|
89
89
|
end
|
90
90
|
tags
|
data/lib/gamerom/repo.rb
CHANGED
data/lib/gamerom/repo_adapter.rb
CHANGED
@@ -12,14 +12,21 @@ module Gamerom
|
|
12
12
|
|
13
13
|
def games(platform)
|
14
14
|
games = []
|
15
|
-
progress_bar = ProgressBar.
|
15
|
+
progress_bar = ProgressBar.create(
|
16
|
+
title: platform,
|
17
|
+
total: sections.count,
|
18
|
+
autofinish: true,
|
19
|
+
length: 80,
|
20
|
+
format: "%t: %b\e[0;93m\u{15E7}\e[0m%i %j%% %e",
|
21
|
+
progress_mark: ' ',
|
22
|
+
remainder_mark: "\e[0;34m\u{FF65}\e[0m"
|
23
|
+
)
|
16
24
|
|
17
25
|
extract_games(platform) do |section_games, section_index|
|
18
26
|
games.append(*section_games)
|
19
|
-
progress_bar.
|
27
|
+
progress_bar.progress = section_index + 1
|
20
28
|
end
|
21
29
|
|
22
|
-
progress_bar.finish
|
23
30
|
games
|
24
31
|
end
|
25
32
|
end
|
@@ -33,6 +33,7 @@ module Gamerom
|
|
33
33
|
'saturn' => 'Sega Saturn',
|
34
34
|
'psx' => 'Sony Playstation',
|
35
35
|
'ps2' => 'Sony Playstation 2',
|
36
|
+
'ps3' => 'Sony Playstation 3',
|
36
37
|
'psp' => 'Sony Playstation Portable',
|
37
38
|
}.freeze
|
38
39
|
|
@@ -48,10 +49,12 @@ module Gamerom
|
|
48
49
|
sections.each_with_index do |section, index|
|
49
50
|
page = nokogiri_get("https://coolrom.com.au/roms/#{platform}/#{section}/")
|
50
51
|
regions = page.css('input.region').map { |i| i['name'] }
|
52
|
+
game_links = []
|
51
53
|
regions.each do |region|
|
52
|
-
|
53
|
-
|
54
|
+
region_game_links = page.css("div.#{region} a")
|
55
|
+
game_links.append(*region_game_links.map { |game_link| game(game_link, region) })
|
54
56
|
end
|
57
|
+
yield game_links, index
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
@@ -11,6 +11,10 @@ module Gamerom
|
|
11
11
|
extend Gamerom::RepoAdapter
|
12
12
|
|
13
13
|
PLATFORM = {
|
14
|
+
'32X' => 'Sega 32X',
|
15
|
+
'Atari2600' => 'Atari 2600',
|
16
|
+
'Atari5200' => 'Atari 5200',
|
17
|
+
'Atari7800' => 'Atari 7800',
|
14
18
|
'Dreamcast' => 'Dreamcast',
|
15
19
|
'DS' => 'Nintendo DS',
|
16
20
|
'GameCube' => 'GameCube',
|
@@ -18,6 +22,8 @@ module Gamerom
|
|
18
22
|
'GBA' => 'Game Boy Advance',
|
19
23
|
'GBC' => 'Game Boy Color',
|
20
24
|
'Genesis' => 'Genesis',
|
25
|
+
'GG' => 'Game Gear',
|
26
|
+
'Lynx' => 'Lynx',
|
21
27
|
'N64' => 'Nintendo 64',
|
22
28
|
'NES' => 'Nintendo',
|
23
29
|
'PS1' => 'PlayStation',
|
@@ -25,9 +31,16 @@ module Gamerom
|
|
25
31
|
'PS3' => 'PlayStation 3',
|
26
32
|
'PSP' => 'PlayStation Portable',
|
27
33
|
'Saturn' => 'Saturn',
|
34
|
+
'SegaCD' => 'Sega CD',
|
35
|
+
'SMS' => 'Master System',
|
28
36
|
'SNES' => 'Super Nintendo',
|
37
|
+
'TG16' => 'TurboGrafx-16',
|
38
|
+
'TGCD' => 'TurboGrafx-CD',
|
39
|
+
'VB' => 'Virtual Boy',
|
29
40
|
'Wii' => 'Wii',
|
30
41
|
'WiiWare' => 'WiiWare',
|
42
|
+
'Xbox' => 'Xbox',
|
43
|
+
'Xbox360' => 'Xbox 360',
|
31
44
|
}.freeze
|
32
45
|
|
33
46
|
def self.platforms
|
@@ -43,6 +56,8 @@ module Gamerom
|
|
43
56
|
page = nokogiri_get("https://vimm.net/vault/?p=list&system=#{platform}§ion=#{section}")
|
44
57
|
game_links = page.css('table.hovertable td:first-child a:first-child')
|
45
58
|
yield game_links.map { |game_link| game(game_link) }, index
|
59
|
+
rescue RestClient::NotFound
|
60
|
+
yield [], index
|
46
61
|
end
|
47
62
|
end
|
48
63
|
|
@@ -60,7 +75,7 @@ module Gamerom
|
|
60
75
|
agent.pluggable_parser.default = Mechanize::Download
|
61
76
|
agent.user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
|
62
77
|
page = agent.get("https://vimm.net/vault/#{game.id}")
|
63
|
-
form = page.form_with(id: '
|
78
|
+
form = page.form_with(id: 'dl_form')
|
64
79
|
|
65
80
|
filenames = []
|
66
81
|
game_files = []
|
data/lib/gamerom/version.rb
CHANGED
data/lib/mechanizeprogress.rb
CHANGED
@@ -31,11 +31,11 @@ class Mechanize
|
|
31
31
|
log.debug("Read #{total} bytes total") if log && !mpbar.suppress_logger? # (7of7)a
|
32
32
|
|
33
33
|
raise Mechanize::ResponseCodeError, response if
|
34
|
-
Net::HTTPUnknownResponse
|
34
|
+
response == Net::HTTPUnknownResponse
|
35
35
|
|
36
36
|
content_length = response.content_length
|
37
37
|
|
38
|
-
unless Net::HTTP::Head
|
38
|
+
unless request == Net::HTTP::Head || response == Net::HTTPRedirection
|
39
39
|
if content_length && content_length != body_io.length
|
40
40
|
raise EOFError, "Content-Length (#{content_length}) does not match response body length (#{body_io.length})"
|
41
41
|
end
|
@@ -46,3 +46,34 @@ class Mechanize
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
# MechanizeProgressBar - A Monkeypatch for the mechanize progressbar
|
51
|
+
class MechanizeProgressBar
|
52
|
+
def inc(step)
|
53
|
+
@progressbar.progress = @progressbar.progress + step if @progressbar
|
54
|
+
end
|
55
|
+
|
56
|
+
def progressbar_new(pbar_opts, request, response)
|
57
|
+
out = pbar_opts[:out] || pbar_opts[:output] || $stderr
|
58
|
+
format = pbar_opts[:format] || "%j%% %b\e[0;93m\u{15E7}\e[0m%i Progress: %c/%C %a %e Speed: %rKB/sec %t"
|
59
|
+
if pbar_opts[:single]
|
60
|
+
title = pbar_opts[:title] || request['Host']
|
61
|
+
else
|
62
|
+
title = pbar_opts[:title] || ''
|
63
|
+
out.print "#{pbar_opts[:title] || uri(request)}\n"
|
64
|
+
end
|
65
|
+
total = pbar_opts[:total] || filesize(response)
|
66
|
+
pbar_class = pbar_opts[:reversed] ? ReversedProgressBar : ProgressBar
|
67
|
+
|
68
|
+
pbar_class.create(
|
69
|
+
title: title,
|
70
|
+
total: total,
|
71
|
+
output: out,
|
72
|
+
length: 120,
|
73
|
+
format: format,
|
74
|
+
rate_scale: ->(rate) { rate / 1024 },
|
75
|
+
progress_mark: ' ',
|
76
|
+
remainder_mark: "\e[0;34m\u{FF65}\e[0m"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamerom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Mundim
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: mechanize
|
@@ -16,14 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
18
|
+
version: 2.14.0
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
25
|
+
version: 2.14.0
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: mechanize-progressbar
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +43,28 @@ dependencies:
|
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
46
|
+
version: 1.18.5
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
53
|
+
version: 1.18.5
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: progressbar
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
60
|
+
version: 1.13.0
|
62
61
|
type: :runtime
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
67
|
+
version: 1.13.0
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
name: rest-client
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +85,14 @@ dependencies:
|
|
86
85
|
requirements:
|
87
86
|
- - "~>"
|
88
87
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
88
|
+
version: 1.3.2
|
90
89
|
type: :runtime
|
91
90
|
prerelease: false
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
93
92
|
requirements:
|
94
93
|
- - "~>"
|
95
94
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
95
|
+
version: 1.3.2
|
97
96
|
description: A command-line installer for game ROMs from many repositories.
|
98
97
|
email:
|
99
98
|
- lucas.mundim@gmail.com
|
@@ -107,6 +106,7 @@ files:
|
|
107
106
|
- ".rspec"
|
108
107
|
- ".rubocop.yml"
|
109
108
|
- ".ruby-version"
|
109
|
+
- ".tool-versions"
|
110
110
|
- CHANGELOG.md
|
111
111
|
- CODE_OF_CONDUCT.md
|
112
112
|
- Dockerfile
|
@@ -129,7 +129,6 @@ files:
|
|
129
129
|
- lib/gamerom/repo.rb
|
130
130
|
- lib/gamerom/repo_adapter.rb
|
131
131
|
- lib/gamerom/repo_adapters/coolrom.rb
|
132
|
-
- lib/gamerom/repo_adapters/romnation.rb
|
133
132
|
- lib/gamerom/repo_adapters/vimm.rb
|
134
133
|
- lib/gamerom/version.rb
|
135
134
|
- lib/mechanizeprogress.rb
|
@@ -141,7 +140,7 @@ metadata:
|
|
141
140
|
homepage_uri: https://github.com/lucasmundim/gamerom
|
142
141
|
source_code_uri: https://github.com/lucasmundim/gamerom
|
143
142
|
changelog_uri: https://github.com/lucasmundim/gamerom/blob/master/CHANGELOG.md
|
144
|
-
|
143
|
+
rubygems_mfa_required: 'true'
|
145
144
|
rdoc_options: []
|
146
145
|
require_paths:
|
147
146
|
- lib
|
@@ -149,15 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
148
|
requirements:
|
150
149
|
- - ">="
|
151
150
|
- !ruby/object:Gem::Version
|
152
|
-
version: 3.
|
151
|
+
version: 3.4.2
|
153
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
153
|
requirements:
|
155
154
|
- - ">="
|
156
155
|
- !ruby/object:Gem::Version
|
157
156
|
version: '0'
|
158
157
|
requirements: []
|
159
|
-
rubygems_version: 3.2
|
160
|
-
signing_key:
|
158
|
+
rubygems_version: 3.6.2
|
161
159
|
specification_version: 4
|
162
160
|
summary: The Video Game ROM downloader
|
163
161
|
test_files: []
|
@@ -1,110 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'cgi'
|
4
|
-
require 'mechanize'
|
5
|
-
require 'mechanize/progressbar'
|
6
|
-
require 'mechanizeprogress'
|
7
|
-
|
8
|
-
module Gamerom
|
9
|
-
module RepoAdapters
|
10
|
-
# Romnation - An adapter for the ROMNation repository website
|
11
|
-
class Romnation
|
12
|
-
extend Gamerom::RepoAdapter
|
13
|
-
|
14
|
-
PLATFORM = {
|
15
|
-
'amstrad' => 'Amstrad',
|
16
|
-
'atari2600' => 'Atari 2600',
|
17
|
-
'atari5200' => 'Atari 5200',
|
18
|
-
'atari7800' => 'Atari 7800',
|
19
|
-
'atarijaguar' => 'Atari Jaguar',
|
20
|
-
'atarilynx' => 'Atari Lynx',
|
21
|
-
'colecovision' => 'ColecoVision',
|
22
|
-
'commodore64' => 'Commodore 64',
|
23
|
-
'gamegear' => 'Game Gear',
|
24
|
-
'gb' => 'Game Boy',
|
25
|
-
'gbc' => 'Game Boy Color',
|
26
|
-
'gcdvectrex' => 'Vectrex',
|
27
|
-
'genesis' => 'Genesis',
|
28
|
-
'intellivision' => 'Intellivision',
|
29
|
-
'mame' => 'MAME',
|
30
|
-
'msx1' => 'MSX',
|
31
|
-
'msx2' => 'MSX2',
|
32
|
-
'mtx' => 'MTX',
|
33
|
-
'n64' => 'N64',
|
34
|
-
'neogeocd' => 'Neo Geo CD',
|
35
|
-
'neogeopocket' => 'Neo Geo Pocket',
|
36
|
-
'nes' => 'NES',
|
37
|
-
'oric' => 'Oric',
|
38
|
-
'pce' => 'PC Engine',
|
39
|
-
'radioshackcolorcomputer' => 'TRS-80',
|
40
|
-
'samcoupe' => 'SAM Coupé',
|
41
|
-
'segacd' => 'Sega CD',
|
42
|
-
'segamastersystem' => 'Master System',
|
43
|
-
'snes' => 'SNES',
|
44
|
-
'thompsonmo5' => 'Thomson MO5',
|
45
|
-
'virtualboy' => 'Virtual Boy',
|
46
|
-
'watara' => 'Watara Supervision',
|
47
|
-
'wonderswan' => 'WonderSwan',
|
48
|
-
}.freeze
|
49
|
-
|
50
|
-
def self.platforms
|
51
|
-
PLATFORM
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.sections
|
55
|
-
('a'..'z').to_a.unshift('0')
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.extract_games(platform)
|
59
|
-
sections.each_with_index do |section, index|
|
60
|
-
pages = extract_pages(platform, section)
|
61
|
-
yield extract_games_from_section_pages(platform, section, pages), index
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.extract_pages(platform, section)
|
66
|
-
page = nokogiri_get("https://www.romnation.net/srv/roms/#{platform}/#{section}/sort-title.html")
|
67
|
-
pages = ['1']
|
68
|
-
pages = page.css('.pagination').first.css('a').map(&:text).map(&:strip).reject(&:empty?) unless page.css('.pagination').empty?
|
69
|
-
pages
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.extract_games_from_section_pages(platform, section, pages)
|
73
|
-
pages.reduce([]) do |section_games, p|
|
74
|
-
page = nokogiri_get("https://www.romnation.net/srv/roms/#{platform}/#{section}/page-#{p}_sort-title.html")
|
75
|
-
games_links = page.css('table.listings td.title a')
|
76
|
-
section_games.append(*games_links.map { |game_link| game(game_link) })
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.game(game_link)
|
81
|
-
game_info = GameInfo.new(game_link.text)
|
82
|
-
{
|
83
|
-
id: game_link['href'].split('/')[3].to_i,
|
84
|
-
name: game_link.text,
|
85
|
-
region: game_info.region,
|
86
|
-
tags: game_info.tags,
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.install(game)
|
91
|
-
agent = Mechanize.new
|
92
|
-
agent.pluggable_parser.default = Mechanize::Download
|
93
|
-
agent.user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
|
94
|
-
page = agent.get("https://www.romnation.net/download/rom/#{game.id}")
|
95
|
-
|
96
|
-
response = nil
|
97
|
-
agent.progressbar do
|
98
|
-
response = page.link_with(text: 'Download This Rom').click
|
99
|
-
end
|
100
|
-
|
101
|
-
return unless response.code.to_i == 200
|
102
|
-
|
103
|
-
filename = CGI.unescape(response.filename.split('_host=').first)
|
104
|
-
FileUtils.mkdir_p(game.filepath)
|
105
|
-
response.save!("#{game.filepath}/#{filename}")
|
106
|
-
yield [filename]
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|