Skip to content

Commit

Permalink
Remove IMDB_XML and IMDB_JSON parsers; fix importer
Browse files Browse the repository at this point in the history
  • Loading branch information
extempl committed Sep 21, 2019
1 parent 222566b commit d829604
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 293 deletions.
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.2.6"
version = "1.2.7"

ext {
guiceVersion = "4.0"
Expand Down Expand Up @@ -32,4 +32,4 @@ dependencies {
testCompile 'org.assertj:assertj-core:3.4.1'
testCompile "com.google.jimfs:jimfs:1.1"
testCompile "org.projectlombok:lombok:$lombokVersion"
}
}
12 changes: 12 additions & 0 deletions core/src/main/java/org/f0w/k2i/core/ConfigValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static Config checkValid(Config config) {
validator.checkAuth();
validator.checkAuthSid();
validator.checkAuthSessionId();
validator.checkAuthUbidMain();
validator.checkAuthControl();
validator.checkMode();
validator.checkList();
Expand Down Expand Up @@ -186,6 +187,17 @@ private void checkAuthSessionId() {
checkArgument(auth.length() > 10, "auth string (sessionId) length is less than or equal to 10!");
}

/**
* Checks the auth ubid-main string
*
* @throws IllegalArgumentException If not valid
*/
private void checkAuthUbidMain() {
val auth = config.getString("authUbidMain");

checkArgument(auth.length() > 10, "auth string (ubid-main) length is less than or equal to 10!");
}

/**
* Checks the auth control pair
*
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/org/f0w/k2i/core/DocumentSourceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* Supported document sources
*/
public enum DocumentSourceType {
IMDB_XML,
OMDB,
IMDB_JSON,
IMDB_HTML,
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public ExchangeObject<Integer> prepare(@NonNull Movie movie) throws IOException
.cookie("session-id", config.getString("authSessionId"))
.cookie("id", config.getString("auth"))
.cookie("sid", config.getString("authSid"))
.cookie("ubid-main", config.getString("authUbidMain"))
.header("Content-Type", "application/x-www-form-urlencoded")
.ignoreContentType(true)
.data(postData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import lombok.val;
import org.f0w.k2i.core.DocumentSourceType;
import org.f0w.k2i.core.exchange.finder.strategy.IMDBHTMLExchangeStrategy;
import org.f0w.k2i.core.exchange.finder.strategy.IMDBJSONExchangeStrategy;
import org.f0w.k2i.core.exchange.finder.strategy.IMDBXMLExchangeStrategy;
import org.f0w.k2i.core.exchange.finder.strategy.OMDBExchangeStrategy;

import java.util.Arrays;
import java.util.stream.Collectors;

import static org.f0w.k2i.core.DocumentSourceType.*;
import static org.f0w.k2i.core.DocumentSourceType.IMDB_HTML;
import static org.f0w.k2i.core.DocumentSourceType.OMDB;

/**
* {@link MovieFinder} factory
Expand All @@ -34,10 +33,6 @@ public MovieFinderFactory(Config config) {
*/
public MovieFinder make(DocumentSourceType documentSourceType) {
switch (documentSourceType) {
case IMDB_XML:
return new BasicMovieFinder(IMDB_XML, new IMDBXMLExchangeStrategy(), config);
case IMDB_JSON:
return new BasicMovieFinder(IMDB_JSON, new IMDBJSONExchangeStrategy(), config);
case IMDB_HTML:
return new BasicMovieFinder(IMDB_HTML, new IMDBHTMLExchangeStrategy(), config);
case OMDB:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public IMDBHTMLExchangeStrategy() {
*/
@Override
public Connection.Request buildRequest(@NonNull final Movie movie) {
val searchLink = "http://www.imdb.com/find";
val searchLink = "http://imdb.com/find";
val queryParams = new ImmutableMap.Builder<String, String>()
.put("q", movie.getTitle())
.put("s", "tt")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions core/src/main/java/org/f0w/k2i/core/parser/IMDBXMLMovieParser.java

This file was deleted.

4 changes: 2 additions & 2 deletions core/src/main/java/org/f0w/k2i/core/parser/MovieParsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ private MovieParsers() {
*/
public static MovieParser ofSourceType(DocumentSourceType documentSourceType) {
switch (documentSourceType) {
case IMDB_XML: return new IMDBXMLMovieParser();
case IMDB_JSON: return new IMDBJSONMovieParser();
// case IMDB_XML: return new IMDBXMLMovieParser();
// case IMDB_JSON: return new IMDBJSONMovieParser();
case IMDB_HTML: return new IMDBHTMLMovieParser();
case OMDB: return new OMDBMovieParser();
default: throw new IllegalArgumentException("Unsupported format!");
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/resources/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"timeout": 3000,
"log_level": "info",
"document_source_types": [
"IMDB_XML",
"IMDB_JSON",
"IMDB_HTML"
],
"mode": "COMBINED",
Expand All @@ -14,6 +12,7 @@
"auth": "",
"authSid": "",
"authSessionId": "",
"authUbidMain": "",
"authControlKey": "",
"authControlValue": "",
"omdbApiKey": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class MovieFinderFactoryTest {
@Test
public void makeSingle() throws Exception {
val classMap = new ImmutableMap.Builder<DocumentSourceType, Class<? extends MovieFinder>>()
.put(IMDB_XML, BasicMovieFinder.class)
.put(IMDB_JSON, BasicMovieFinder.class)
.put(IMDB_HTML, BasicMovieFinder.class)
.build();

Expand All @@ -30,8 +28,6 @@ public void makeSingle() throws Exception {

@Test
public void makeMultiple() throws Exception {
assertTrue(factory.make(IMDB_XML, IMDB_JSON, IMDB_HTML) instanceof MixedMovieFinder);

assertTrue(factory.make(new DocumentSourceType[]{IMDB_XML}) instanceof BasicMovieFinder);
assertTrue(factory.make(IMDB_HTML) instanceof MixedMovieFinder);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d829604

Please sign in to comment.