Skip to content

Commit 6c66fce

Browse files
committed
Merge branch 'release'
2 parents bfc6878 + fe7bdab commit 6c66fce

File tree

7 files changed

+108
-35
lines changed

7 files changed

+108
-35
lines changed

.github/workflows/codeql.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "dev" ]
6+
pull_request:
7+
branches: [ "dev" ]
8+
schedule:
9+
- cron: "19 12 * * 5"
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ java ]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v2
31+
with:
32+
languages: ${{ matrix.language }}
33+
queries: +security-and-quality
34+
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v2
37+
38+
- name: Perform CodeQL Analysis
39+
uses: github/codeql-action/analyze@v2
40+
with:
41+
category: "/language:${{ matrix.language }}"

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
# Table of Contents
22

3+
- [v3.0.3](#v303): 2023-01-03
34
- [v3.0.2](#v302): 2022-12-18
45
- [v3.0.1](#v301): 2022-12-16
56
- [v3.0.0](#v300): 2022-12-14
67
- [v2.9.0](#v290): 2022-02-20
78

9+
# v3.0.3
10+
11+
## Dependencies
12+
13+
- ⬆️ Upgrade: dependency `common-utils` from `0.13.0` to `0.14.0`
14+
- ⬆️ Upgrade: dependency `annotations` from `23.0.0` to `23.1.0`
15+
- ⬆️ Upgrade: dependency `slf4j-api` from `2.0.4` to `2.0.6`
16+
- ⬆️ Upgrade: dependency `logback-classic` from `1.3.5` to `1.4.5`
17+
- ⬆️ Upgrade: test dependency `mockito-inline` from `4.10.0` to `4.11.0`
18+
- ⬆️ Upgrade: build dependency `gmavenplus-plugin` from `1.13.1` to `2.1.0`
19+
20+
## Troubleshooting
21+
22+
- 🐞 Fix: termination of application
23+
- 🐞 Fix: unreproducible issue that failure to get image count
24+
825
# v3.0.2
926

1027
## Dependencies

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@
77
<p align="center">Downloader for lezhin comics</p>
88

99
<p align="center">
10-
<a href="https://lgtm.com/projects/g/ImSejin/lezhin-comics-downloader/context:java">
11-
<img alt="Lgtm grade" src="https://img.shields.io/lgtm/grade/java/github/ImSejin/lezhin-comics-downloader.svg?logo=&logoWidth=&label=lgtm%3A%20code%20quality&&style=flat-square"/>
10+
<a href="https://sonarcloud.io/summary/new_code?id=ImSejin_lezhin-comics-downloader">
11+
<img alt="Sonarcloud Security Rating" src="https://sonarcloud.io/api/project_badges/measure?project=ImSejin_lezhin-comics-downloader&metric=security_rating"/>
12+
</a>
13+
<a href="https://sonarcloud.io/summary/new_code?id=ImSejin_lezhin-comics-downloader">
14+
<img alt="Sonarcloud Maintainability Rating" src="https://sonarcloud.io/api/project_badges/measure?project=ImSejin_lezhin-comics-downloader&metric=sqale_rating"/>
1215
</a>
1316
<a href="https://app.codacy.com/gh/ImSejin/lezhin-comics-downloader/dashboard">
14-
<img alt="Codacy grade" src="https://img.shields.io/codacy/grade/1a2400c31a8346ddbf108fb3ac78f481?label=codacy%3A%20code%20quality&style=flat-square">
17+
<img alt="Codacy grade" src="https://img.shields.io/codacy/grade/1a2400c31a8346ddbf108fb3ac78f481?style=flat&logo=codacy">
1518
</a>
16-
<img alt="jdk11" src="https://img.shields.io/badge/jdk-11-orange?style=flat-square">
19+
<img alt="jdk11" src="https://img.shields.io/badge/jdk-11-orange?style=flat">
1720
<br/>
18-
<img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/imsejin/lezhin-comics-downloader/total?style=flat-square">
19-
<img alt="GitHub Releases" src="https://img.shields.io/github/downloads/imsejin/lezhin-comics-downloader/latest/total?style=flat-square">
21+
<img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/imsejin/lezhin-comics-downloader/total?style=flat">
22+
<img alt="GitHub Releases" src="https://img.shields.io/github/downloads/imsejin/lezhin-comics-downloader/latest/total?style=flat">
2023
<a href="https://github.com/ImSejin/lezhin-comics-downloader/releases/latest">
21-
<img alt="Latest release" src="https://img.shields.io/github/v/release/ImSejin/lezhin-comics-downloader?color=orange&style=flat-square">
24+
<img alt="Latest release" src="https://img.shields.io/github/v/release/ImSejin/lezhin-comics-downloader?color=orange&style=flat">
2225
</a>
2326
</p>
2427

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.imsejin</groupId>
88
<artifactId>lezhin-comics-downloader</artifactId>
9-
<version>3.0.2</version>
9+
<version>3.0.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Lezhin Comics Downloader</name>
@@ -41,23 +41,23 @@
4141
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4242

4343
<!-- Dependency versions -->
44-
<common-utils.version>0.13.0</common-utils.version>
44+
<common-utils.version>0.14.0</common-utils.version>
4545
<commons-cli.version>1.5.0</commons-cli.version>
4646
<progressbar.version>0.9.4</progressbar.version>
4747
<reftrofit.version>2.9.0</reftrofit.version>
4848
<selenium.version>4.6.0</selenium.version>
4949
<reflections.version>0.10.2</reflections.version>
5050
<lombok.version>1.18.24</lombok.version>
5151
<mapstruct.version>1.5.3.Final</mapstruct.version>
52-
<jetbrains-annotations.version>23.0.0</jetbrains-annotations.version>
53-
<logback-classic.version>1.3.5</logback-classic.version>
54-
<slf4j-api.version>2.0.4</slf4j-api.version>
52+
<jetbrains-annotations.version>23.1.0</jetbrains-annotations.version>
53+
<logback-classic.version>1.4.5</logback-classic.version>
54+
<slf4j-api.version>2.0.6</slf4j-api.version>
5555

5656
<!-- Test dependency versions -->
5757
<junit5.version>5.9.1</junit5.version>
5858
<assertj.version>3.23.1</assertj.version>
5959
<spock.version>2.3-groovy-4.0</spock.version>
60-
<mockito.version>4.10.0</mockito.version>
60+
<mockito.version>4.11.0</mockito.version>
6161
</properties>
6262

6363
<!-- Enables to build on development environment -->
@@ -329,7 +329,7 @@
329329
<plugin>
330330
<groupId>org.codehaus.gmavenplus</groupId>
331331
<artifactId>gmavenplus-plugin</artifactId>
332-
<version>1.13.1</version>
332+
<version>2.1.0</version>
333333
<executions>
334334
<execution>
335335
<goals>

src/main/java/io/github/imsejin/dl/lezhin/Application.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ public static void main(String[] args) {
5858
for (Processor processor : processors) {
5959
Object attribute = processor.process(context);
6060
context.add(attribute);
61-
// context = ProcessContext.of(context, attribute);
6261
}
6362
} catch (Exception e) {
64-
WebBrowser.quitIfInitialized();
6563
Loggers.getLogger().error("Failed to perform a process", e);
64+
} finally {
65+
WebBrowser.quitIfInitialized();
6666
}
6767
}
6868

src/main/java/io/github/imsejin/dl/lezhin/process/impl/AccessTokenProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public AccessToken process(ProcessContext context) throws AccessTokenNotFoundExc
9696
}
9797

9898
AccessToken accessToken = new AccessToken(token);
99-
Loggers.getLogger().info("Successfully logged in: access token({})", accessToken.getValue());
99+
Loggers.getLogger().info("Successfully logged in: access token({})", token);
100100

101101
return accessToken;
102102
}

src/main/java/io/github/imsejin/dl/lezhin/process/impl/DownloadProcessor.java

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@
6666
@ProcessSpecification(dependsOn = DirectoryCreationProcessor.class)
6767
public class DownloadProcessor implements Processor {
6868

69-
private static final Map<Locale, DownloadProcessor> IMPLEMENTATION_MAP = Map.ofEntries(
70-
Map.entry(Locale.KOREA, new KoreanImpl()),
71-
Map.entry(Locale.US, new EnglishImpl()),
72-
Map.entry(Locale.JAPAN, new EnglishImpl())
69+
private static final Map<Locale, ImageCountResolver> IMPLEMENTATION_MAP = Map.ofEntries(
70+
Map.entry(Locale.KOREA, new UsingService()),
71+
Map.entry(Locale.US, new VisitingPage()),
72+
Map.entry(Locale.JAPAN, new VisitingPage())
7373
);
7474

7575
@Override
7676
public Void process(ProcessContext context) throws DirectoryCreationException {
7777
Locale locale = context.getLanguage().getValue();
7878

79-
DownloadProcessor impl = IMPLEMENTATION_MAP.get(locale);
80-
impl.prepare(context);
79+
ImageCountResolver imageCountResolver = IMPLEMENTATION_MAP.get(locale);
80+
imageCountResolver.prepare(context);
8181

8282
AuthorityService service = new AuthorityService(locale, context.getAccessToken().getValue());
8383

@@ -95,7 +95,18 @@ public Void process(ProcessContext context) throws DirectoryCreationException {
9595
continue;
9696
}
9797

98-
int imageCount = impl.getImageCountOfEpisode(context, episode);
98+
int imageCount;
99+
try {
100+
imageCount = imageCountResolver.getImageCountOfEpisode(context, episode);
101+
} catch (NullPointerException ignored) {
102+
// TODO: Remove the below code if solve the issue (#153).
103+
// See https://github.com/ImSejin/lezhin-comics-downloader/issues/153
104+
UsingService impl = (UsingService) imageCountResolver;
105+
Loggers.getLogger().debug("Failed to get image count of episode[{}]: (UsingService.imageCountMap={})",
106+
episode, impl.imageCountMap);
107+
imageCountResolver = IMPLEMENTATION_MAP.get(Locale.US);
108+
imageCount = imageCountResolver.getImageCountOfEpisode(context, episode);
109+
}
99110

100111
// If episode has no image, skips this episode.
101112
if (imageCount < 1) {
@@ -141,20 +152,21 @@ public Void process(ProcessContext context) throws DirectoryCreationException {
141152

142153
// -------------------------------------------------------------------------------------------------
143154

144-
void prepare(ProcessContext context) {
145-
}
155+
/**
156+
* @since 3.0.3
157+
*/
158+
private interface ImageCountResolver {
159+
default void prepare(ProcessContext context) {
160+
}
146161

147-
int getImageCountOfEpisode(ProcessContext context, Episode episode) {
148-
throw new UnsupportedOperationException("Not implemented");
162+
int getImageCountOfEpisode(ProcessContext context, Episode episode);
149163
}
150164

151-
// -------------------------------------------------------------------------------------------------
152-
153-
private static final class KoreanImpl extends DownloadProcessor {
165+
private static final class UsingService implements ImageCountResolver {
154166
private Map<String, Integer> imageCountMap;
155167

156168
@Override
157-
void prepare(ProcessContext context) {
169+
public void prepare(ProcessContext context) {
158170
UUID token = context.getAccessToken().getValue();
159171
String contentAlias = context.getContent().getAlias();
160172
EpisodeImageCountService service = new EpisodeImageCountService(token);
@@ -163,14 +175,14 @@ void prepare(ProcessContext context) {
163175
}
164176

165177
@Override
166-
int getImageCountOfEpisode(ProcessContext context, Episode episode) {
178+
public int getImageCountOfEpisode(ProcessContext context, Episode episode) {
167179
return this.imageCountMap.get(episode.getName());
168180
}
169181
}
170182

171-
private static final class EnglishImpl extends DownloadProcessor {
183+
private static final class VisitingPage implements ImageCountResolver {
172184
@Override
173-
int getImageCountOfEpisode(ProcessContext context, Episode episode) {
185+
public int getImageCountOfEpisode(ProcessContext context, Episode episode) {
174186
Language language = context.getLanguage();
175187

176188
String episodeUrl;

0 commit comments

Comments
 (0)