Fix search: add old_ent category, fix thumbnail URL, improve title extraction
This commit is contained in:
@@ -547,41 +547,48 @@ class TvmonScraper {
|
||||
val results = mutableListOf<Content>()
|
||||
val seen = mutableSetOf<String>()
|
||||
|
||||
val allLinks = doc.select("a[href*='/movie/'], a[href*='/drama/'], a[href*='/ent/'], a[href*='/world/'], a[href*='/animation/'], a[href*='/kor_movie/']")
|
||||
val allLinks = doc.select("a.poster[href*='/movie/'], a.poster[href*='/drama/'], a.poster[href*='/ent/'], a.poster[href*='/world/'], a.poster[href*='/animation/'], a.poster[href*='/kor_movie/'], a.poster[href*='/old_ent/'], a.poster[href*='/sisa/'], a.poster[href*='/ott_ent/'], a.poster[href*='/ani_movie/']")
|
||||
|
||||
for (link in allLinks) {
|
||||
val href = link.attr("href")
|
||||
if (href.isBlank()) continue
|
||||
for (link in allLinks) {
|
||||
val href = link.attr("href")
|
||||
if (href.isBlank()) continue
|
||||
|
||||
val fullUrl = resolveUrl(href)
|
||||
if (fullUrl in seen) continue
|
||||
if (NAV_PATTERNS.any { it in fullUrl }) continue
|
||||
seen.add(fullUrl)
|
||||
val fullUrl = resolveUrl(href)
|
||||
if (fullUrl in seen) continue
|
||||
if (NAV_PATTERNS.any { it in fullUrl }) continue
|
||||
seen.add(fullUrl)
|
||||
|
||||
val idMatch = Pattern.compile("/(\\d+)(?:/|\\$|\\?)").matcher(href)
|
||||
val contentId = if (idMatch.find()) idMatch.group(1) else ""
|
||||
val idMatch = Pattern.compile("/(\\d+)(?:/|\\$|\\?)").matcher(href)
|
||||
val contentId = if (idMatch.find()) idMatch.group(1) else ""
|
||||
|
||||
val category = getCategoryFromUrl(href)
|
||||
val category = getCategoryFromUrl(href)
|
||||
|
||||
val imgTag = link.selectFirst("img")
|
||||
val imgUrl = imgTag?.attr("src") ?: imgTag?.attr("data-src") ?: ""
|
||||
val imgTag = link.selectFirst("img")
|
||||
var imgUrl = imgTag?.attr("src") ?: imgTag?.attr("data-src") ?: ""
|
||||
// 상대 경로인 경우 BASE_URL을 앞에 붙임
|
||||
if (imgUrl.isNotBlank() && !imgUrl.startsWith("http")) {
|
||||
imgUrl = BASE_URL + imgUrl
|
||||
}
|
||||
|
||||
var title = link.text()
|
||||
if (title.isBlank()) {
|
||||
val titleTag = link.selectFirst(".title, .movie-title")
|
||||
title = titleTag?.text() ?: ""
|
||||
}
|
||||
var title = ""
|
||||
val titleLink = link.parent()?.selectFirst("a.title")
|
||||
if (titleLink != null) {
|
||||
title = titleLink.text().trim()
|
||||
}
|
||||
if (title.isBlank()) {
|
||||
title = link.attr("title").ifBlank { link.text().trim() }
|
||||
}
|
||||
|
||||
if (title.isNotBlank()) {
|
||||
results.add(Content(
|
||||
id = contentId ?: "",
|
||||
title = title,
|
||||
url = fullUrl,
|
||||
thumbnail = imgUrl,
|
||||
category = category
|
||||
))
|
||||
}
|
||||
}
|
||||
if (title.isNotBlank()) {
|
||||
results.add(Content(
|
||||
id = contentId ?: "",
|
||||
title = title,
|
||||
url = fullUrl,
|
||||
thumbnail = imgUrl,
|
||||
category = category
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
SearchResult(
|
||||
success = true,
|
||||
|
||||
Reference in New Issue
Block a user