Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
Bon j'avais rien à faire dcp j'ai juste modifié 2 3 trucs
Browse files Browse the repository at this point in the history
  • Loading branch information
Minemobs committed Mar 6, 2021
1 parent fe83989 commit 63dd581
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,4 @@ public class Main {
}
}
}
}

```
}
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ plugins {

mainClassName = "fr.minemobs.animes.Test"

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.google.code.gson:gson:2.8.6'
compile "org.jsoup:jsoup:1.10.2"
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.0'
}
33 changes: 22 additions & 11 deletions src/main/java/fr/minemobs/animes/AnimeSearcherAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import okhttp3.*;
import okhttp3.OkHttpClient.Builder;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.*;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.stream.Collectors;

public class AnimeSearcherAPI {

String urlOfNekoSama = "http://neko-sama.fr";
String jsonUrl = urlOfNekoSama + "/animes-search.json";

String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11";
private static Logger LOGGER = Logger.getLogger(AnimeSearcherAPI.class.getName());

OkHttpClient httpClient = new OkHttpClient.Builder()
.protocols(Collections.singletonList(Protocol.HTTP_1_1))
Expand Down Expand Up @@ -69,12 +67,13 @@ public List<Anime> getJSONFromTitleContains(String animeTitle) {
Type animeListType = new TypeToken<List<Anime>>() {
}.getType();
List<Anime> animes = gson.fromJson(responseBody, animeListType);
List<Anime> animes1 = animes.stream().filter(anime1 -> anime1.getTitle().toLowerCase().contains(animeTitle.toLowerCase())).collect(Collectors.toList());
List<Anime> animes1 = animes.stream()
.filter(anime1 -> anime1.getTitle().toLowerCase().contains(animeTitle.toLowerCase())).collect(Collectors.toList());
return animes1;
}

public AnimeHtml getHtmlPageOfTheAnime(Anime anime, int episodeSearched) throws Exception {
if(Jsoup.connect(anime.getUrl()).get() == null){
if(anime.getUrl() == null || Jsoup.connect(anime.getUrl()).get() == null){
throw new NullPointerException("Cet anime n'a pas de page");
}
Document doc = Jsoup.connect(anime.getUrl()).get();
Expand Down Expand Up @@ -111,4 +110,16 @@ public String getJsonUrl() {
public String getUrlOfNekoSama() {
return urlOfNekoSama;
}

public OkHttpClient getHttpClient() {
return httpClient;
}

public Request getRequest() {
return request;
}

public static Logger getLOGGER() {
return LOGGER;
}
}

0 comments on commit 63dd581

Please sign in to comment.