Compare commits
3 Commits
72aafc1d70
...
main
Author | SHA1 | Date | |
---|---|---|---|
d988bd3155 | |||
1fb56a2dee
|
|||
059aebddc7
|
@ -14,7 +14,8 @@ public class CacheConfig {
|
||||
"kodikIDPlayerLink",
|
||||
"shikimoriIDPlayerLink",
|
||||
"kinopoiskIDPlayerLink",
|
||||
"imdbIDPlayerLink");
|
||||
"imdbIDPlayerLink",
|
||||
"kodikPage");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,8 +40,10 @@ public class KodikHtmlParserService {
|
||||
|
||||
private List<KodikTranslation> parseTranslations(Document doc) {
|
||||
List<KodikTranslation> translations = new ArrayList<>();
|
||||
String videoType = findVideoType(doc.html()).orElse("serial");
|
||||
Elements translationOptions = doc.select(".serial-translations-box select option");
|
||||
String possibleMediaType = findVideoType(doc.html()).orElse("serial");
|
||||
boolean isMovie = possibleMediaType.equals("video");
|
||||
String videoType = isMovie ? "movie" : possibleMediaType;
|
||||
Elements translationOptions = doc.select(String.format(".%s-translations-box select option", videoType));
|
||||
|
||||
for (Element option : translationOptions) {
|
||||
String id = option.attr("value");
|
||||
@ -50,14 +52,14 @@ public class KodikHtmlParserService {
|
||||
String mediaHash = option.attr("data-media-hash");
|
||||
String mediaType = option.attr("data-media-type");
|
||||
String translationType = option.attr("data-translation-type");
|
||||
int episodeCount = parseIntSafely(option.attr("data-episode-count"));
|
||||
int episodeCount = isMovie ? 1 : parseIntSafely(option.attr("data-episode-count"));
|
||||
|
||||
translations.add(new KodikTranslation(id, title, mediaId, mediaHash,
|
||||
mediaType, translationType, episodeCount));
|
||||
}
|
||||
|
||||
Elements seasonOptions = doc.select(".serial-seasons-box select option");
|
||||
Elements seriesOptions = doc.select(".serial-series-box select option");
|
||||
Elements seasonOptions = doc.select(String.format(".%s-seasons-box select option", videoType));
|
||||
Elements seriesOptions = doc.select(String.format(".%s-series-box select option", videoType));
|
||||
if (translations.isEmpty()) {
|
||||
for (Element option : seasonOptions) {
|
||||
if (!option.hasAttr("selected")) {
|
||||
@ -69,7 +71,8 @@ public class KodikHtmlParserService {
|
||||
String mediaHash = option.attr("data-serial-hash");
|
||||
|
||||
translations
|
||||
.add(new KodikTranslation(id, title, mediaId, mediaHash, videoType, "", seriesOptions.size()));
|
||||
.add(new KodikTranslation(id, title, mediaId, mediaHash, possibleMediaType, "",
|
||||
seriesOptions.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.backend.extractor.kodik.service.anyame_backend.api.model.KodikVideoLinks;
|
||||
@ -28,6 +29,7 @@ public class KodikNetworkService {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Cacheable("kodikPage")
|
||||
public String fetchPage(String url) throws IOException {
|
||||
Request request = new Request.Builder()
|
||||
.url(normalizeUrl(url))
|
||||
|
Reference in New Issue
Block a user