Giter VIP home page Giter VIP logo

kotlininside's Introduction

KotlinInside Build Status Maven Central

Kotlin으로 작성한 디시인사이드 비공식 API입니다.

API 문서

Gradle

< Gradle 7

compile 'be.zvz:KotlinInside:1.16.2'

Gradle 7+

implementation 'be.zvz:KotlinInside:1.16.2'

Maven

<dependency>
  <groupId>be.zvz</groupId>
    <artifactId>KotlinInside</artifactId>
    <version>1.16.2</version>
</dependency>

라이브러리 최소 요구사항

  • Java 1.8 (Java 8) 이상 필요
  • Kotlin 1.9+ 권장
  • Android에서 사용 가능
  • Java에서도 사용 가능 (타 JVM 계열 언어에서도 사용 가능)

라이브러리 컴파일 최소 요구사항

  • Java 1.8 (Java 8) 이상 필요

예제

Init

유동 닉네임

KotlinInside.createInstance(
    Anonymous("이름", "비밀번호"),
    DefaultHttpClient()
)

고정 닉네임

KotlinInside.createInstance(
    LoginUser("아이디", "비밀번호"),
    DefaultHttpClient()
)

글 목록 받아오기

val articleList = ArticleList("hit", 1)
articleList.request()

val gallList = articleList.getGallList() // 글 목록
val gallInfo = articleList.getGallInfo() // 갤러리 정보

println(gallInfo)
gallList.forEach {
    println(it)
}

글 읽기

val articleRead = ArticleRead("hit", 1)
articleRead.request()

println(articleRead.getViewInfo())
println(articleRead.getViewMain())

더 자세한 예제는 테스트 코드 참고

이 라이브러리를 사용 중인 프로젝트

도움이 된 라이브러리

라이선스

GPLv3

본 라이브러리에 포함되어 있는 라이브러리

Copyright 2019 sedmelluq. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 Licence (BSD):
 ==============

 Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (base64 @ miginfocom . com)
 All rights reserved.

 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
 Redistributions of source code must retain the above copyright notice, this list
 of conditions and the following disclaimer.
 Redistributions in binary form must reproduce the above copyright notice, this
 list of conditions and the following disclaimer in the documentation and/or other
 materials provided with the distribution.
 Neither the name of the MiG InfoCom AB nor the names of its contributors may be
 used to endorse or promote products derived from this software without specific
 prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 OF SUCH DAMAGE.

kotlininside's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar ilsubyeega avatar jellybrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kotlininside's Issues

app_id를 받아올 수 없는 문제

[{result: false, cause: "bad"}]

2019/10/25 14시경부터 기존의 코드가 작동하지 않음

(구버전 공식앱 또한 bad를 띄웠지만, 15시경 해결된 것으로 보임)

app_id 받아오는 로직에 변화가 생긴 것으로 추정

글 작성이 종종 실패하는 문제

WriteResult(result=false, articleId=null, cause=잠시후 다시 이용해주세요., id=null)

잠시후 다시 이용해주세요.라는 메시지만 나오며 글이 작성되지 않습니다.

app_id를 확인해본 결과,
디시 공앱은 WTF....z0=
app_id 키젠은 bExI.....z0=
으로, 서로 다른 결과가 나오는 것을 확인할 수 있었습니다.

libnative-lib.so 바이너리 자체는 전과 차이가 없는 것 같습니다.

Kotlin coroutine 지원 추가

val articleList = ArticleList("hit", 1)
launch {
    articleList.request()

    val gallList = articleList.getGallList() // 글 목록
    val gallInfo = articleList.getGallInfo() // 갤러리 정보

    println(gallInfo)
    gallList.forEach {
        println(it)
    }
}

logger.info("When will this code executed?")

Q. 글이나 댓글 작성시 `잠시후 다시 시도해주세요.`가 떠요!

원인

  • API 키를 발급 받은 직후에는 글 작성을 할 수 없습니다.
  • 올바르지 않은 client_token이 입력되었습니다.

해결 방법

  • API 키를 발급 받고 나서, 5초 정도의 딜레이가 필요합니다.
  • 올바른 client_token (fcmToken) 을 입력하거나, KotlinInside의 기본값을 사용합니다.

분석 및 수정 : app_id 인증 방법이 변경됨

이제 app_id 키를 받아오기 위해
client_token이 필요합니다.

기존

value_token : 필수
signature : 필수
pkg : 선택
vCode : 선택
vName : 선택

현재

value_token : 필수
signature : 필수
pkg : 제거
vCode : 선택
vName : 선택
client_token : 필수

올바르지 않은 client_token을 입력할 경우 bad를 반환합니다.

`Trust anchor for certification path not found`로 인해 app_id를 받아올 수 없는 경우

  • 2023-5 기준, 디시인사이드 app id 서버에 인증서 문제가 있는 것으로 보임
  • 인증서 문제가 해결된 JDK로 교체하거나 InstallCert와 같은 tool을 사용하여 keystore를 업데이트하면 해결됨
  • 혹은 HttpClient를 상속하여 커스텀 인증서를 사용하게끔 구현하거나, 인증서 검사를 우회하게 구현하면 해결됨

구조 개편

현재 구조로는 애플리케이션에서 사용하기가 어려움

  • 클래스 구조 개편
  • 클래스 네이밍 개편
  • 패키지 구조 개편
  • 세션 핸들링 방식 변경
  • Exception 핸들링 방식 변경 (API 요청 result, cause 관련)

뎃글 작성이 안되는것 같음

val commentWrite = CommentWrite(
gallId = "갤러리id",
articleId = 글 번호,
comment = StringComment(
memo = "ssss"
),
session = KotlinInside.getInstance().session
)

이렇게 쓰는거 맞나요?
오류는 안나는데 확인 해보면 뎃글은 작성이 안되어 있네요

`ArticleRead`에서 session 주입 시 데이터 미반환

image

세션 입력 코드

import be.zvz.kotlininside.KotlinInside
import be.zvz.kotlininside.http.DefaultHttpClient
import be.zvz.kotlininside.session.user.Anonymous
import be.zvz.kotlininside.session.user.LoginUser

KotlinInside.createInstance(
    LoginUser("ilsubyeega", "<redacted>"),
    DefaultHttpClient()
)

val session = KotlinInside.getInstance().session

sessionAutoRefresh가 동작하지 않음

KotlinInside.createInstance의 sessionAutoRefresh가 true여도 장시간 실행 시 글 쓰기, 읽기 등을 할 수 없게 됩니다.

13:00~00:59 사이에 생성된 인스턴스 -> 다음 13:00에 만료
01:00~12:59 사이에 생성된 인스턴스 -> 12시간 후 만료

Jackson `ObjectMapper` 활용

현재 상황

ObjectMapper.readValue(json, clazz)를 활용하지 않고, JsonBrowser 사용 중

문제점

  • 가독성이 낮음
  • 최적화의 여지가 낮음 (Jackson Afterburner, Blackbird, ...etc)

작업시 예상되는 걸림돌

  • 기괴한 네이밍 규칙으로 인해 추가 작업 필요
  • y / n / null / undefinedBoolean 값으로 변환할 수 있어야 함
  • 특정 값은 null이면 안 되고, 반드시 기본 값을 가져야 함

만든 인스턴스를 재사용 하는법?

안녕하세요. KotlinInside를 잘 사용하고 있는 사람입니다.
KotlinInside를 이용한 프로그램을 실행할 때 마다 인스턴스를 계속 생성하게 되는데 기존에 만든 인스턴스를 프로그램 재시작후에도 재사용할 수 있는 방법이 있는지 궁금합니다.

댓글 글쓴이의 ipData를 받아올 수 없습니다.

import be.zvz.kotlininside.KotlinInside
import be.zvz.kotlininside.api.article.ArticleList
import be.zvz.kotlininside.api.comment.CommentRead
import be.zvz.kotlininside.api.type.comment.StringComment
import be.zvz.kotlininside.http.DefaultHttpClient
import be.zvz.kotlininside.session.user.Anonymous
import java.lang.IllegalStateException

fun croller(id: String) {
    val articleList = ArticleList(id, 1, true)
    articleList.request()

    val gallList = articleList.getGallList() // 글 목록
    val gallInfo = articleList.getGallInfo() // 갤러리 정보

    println(gallInfo.title)
    gallList.forEach {
            val totalPages = CommentRead(id, it.identifier, 1).get().totalPage
            println(it.subject)

            for (i in 1..totalPages) {
                println(i)
                val reader = CommentRead(id, it.identifier, i)
                val comments = reader.get().commentList

                for (comment in comments) {
                    val content = comment.content
                    if (content is StringComment) {
                        println(content.memo)
                    }
                }
            }
    }
}

fun main(args: Array<String>) {
    KotlinInside.createInstance(
        Anonymous("ㅇㅇ", "1234"),
        DefaultHttpClient(true, true)
    )

    val galleryList = arrayOf("leagueoflegends3", "baseball_new9")
    galleryList.forEach {
        croller(it)
    }
}

위와 같은 간단한 코드를 실행해서, 댓글 데이터들을 크롤링하고 있었습니다. 하지만 특정 글의 댓글 페이지에서 다음과 같은 오류가 발생합니다.

Exception in thread "main" java.lang.IllegalStateException: it.get("ipData").text() must not be null
	at be.zvz.kotlininside.api.comment.CommentRead.get(CommentRead.kt:54)
	at MainKt.croller(main.kt:24)
	at MainKt.main(main.kt:44)

확인해보니 몇몇 댓글들은 ipData를 받아올 수 없어, IllegalStateException이 발생하는 것 같습니다. 확인해주시길 바랍니다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.