diff --git a/msedgedriver.exe b/msedgedriver.exe index 170ee24..82e36bd 100644 --- a/msedgedriver.exe +++ b/msedgedriver.exe Binary files differ diff --git a/src/main/kotlin/net/taehui/twilight/system/SiteHandler.kt b/src/main/kotlin/net/taehui/twilight/system/SiteHandler.kt index 37953f1..0c541aa 100644 --- a/src/main/kotlin/net/taehui/twilight/system/SiteHandler.kt +++ b/src/main/kotlin/net/taehui/twilight/system/SiteHandler.kt @@ -18,6 +18,7 @@ val commentSiteID: UUID = UUID.fromString("00000000-0000-0000-0000-000000000000") val defaultSiteID: UUID = UUID.fromString("00000000-0000-0000-0000-000000000001") val platformSiteID: UUID = UUID.fromString("00000000-0000-0000-0000-000000000002") + val toNotifySiteID: UUID = UUID.fromString("00000000-0000-0000-0000-000000000003") init { val defaultSite = Site( @@ -49,6 +50,15 @@ platformSite.setSiteYells(DB.getSiteYells(platformSiteID.toString())) sites[platformSiteID] = platformSite } + val toNotifySite = Site( + toNotifySiteID, "@Notify", + isEditable = false, + isGetNotify = true, + isEssential = true, + hasAvatar = true + ) + toNotifySite.setSiteYells(DB.getSiteYells(toNotifySiteID.toString())) + sites[toNotifySiteID] = toNotifySite } fun send(siteID: UUID, event: EventOuterClass.Event) { @@ -401,6 +411,7 @@ fun getSiteID(siteID: String): UUID { return when (siteID) { + "@Notify" -> toNotifySiteID "@Comment" -> commentSiteID "@Default" -> defaultSiteID "@Platform" -> platformSiteID diff --git a/src/main/kotlin/net/taehui/twilight/system/TVSystem.kt b/src/main/kotlin/net/taehui/twilight/system/TVSystem.kt index de09122..782e1a6 100644 --- a/src/main/kotlin/net/taehui/twilight/system/TVSystem.kt +++ b/src/main/kotlin/net/taehui/twilight/system/TVSystem.kt @@ -51,13 +51,13 @@ future = ses.scheduleWithFixedDelay({ tv?.let { it -> it.get("https://www.twitch.tv/directory/game/Qwilight") - val dataTest = By.cssSelector("[data-test-selector=TitleAndChannel]") - val elements = try { + val test0 = By.cssSelector("[data-test-selector=TitleAndChannel]") + val elements0 = try { WebDriverWait( it, Duration.ofSeconds(1) - ).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(dataTest)) - it.findElements(dataTest) ?: throw TimeoutException() + ).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(test0)) + it.findElements(test0) ?: throw TimeoutException() } catch (e: TimeoutException) { emptyList() }.map { element -> @@ -67,6 +67,34 @@ element.findElement(By.tagName("p")).text ) }.toSet() + + it.get("https://chzzk.naver.com/search?query=Qwilight") + + val test1 = + By.cssSelector("#layout-body > div > section > section") + val elements1 = try { + WebDriverWait( + it, + Duration.ofSeconds(1) + ).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(test1)) + it.findElements(test1).filter { + it.findElement(By.cssSelector("strong")).text == "라이브" + }.map { + it.findElements(By.cssSelector("div > ul > li")) + } + } catch (e: TimeoutException) { + emptyList() + }.flatten().map { + val titleElement = it.findElement(By.cssSelector("div > div > div > a")) + TVItem( + titleElement.getAttribute("href"), + titleElement.text.split("\n")[0], + it.findElement(By.cssSelector("div > div > div > div")).text.split("\n")[0] + ) + }.toSet() + + val elements = elements0.plus(elements1) + elements.subtract(lastElements).filter { pendingElements.remove(it) == null }.forEach {