Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions pkg/msbimport/import_kakao.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
"os/exec"
"path"
"path/filepath"
"strings"
"regexp"
"strconv"

log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -192,11 +193,24 @@ func fetchKakaoDetailsFromShareLink(link string) (string, string, error) {
log.Errorln("fetchKakaoDetailsFromShareLink: failed httpGetAndroidUA!", err)
return "", "", err
}
split1 := strings.Split(res, "kakaotalk://store/emoticon/")
if len(split1) < 2 {

eidRegex := regexp.MustCompile(`data-i="(\d+)"`)
rawEid := eidRegex.FindStringSubmatch(res)[1]
rawEidInt, err := strconv.Atoi(string(rawEid))
if err != nil {
log.Errorln("fetchKakaoDetailsFromShareLink: failed to parse rawEid!", err)
return "", "", errors.New("error fetchKakaoDetailsFromShareLink")
}
xorKeysRegex := regexp.MustCompile(`(\d+)\^(\d+)`)
xorKeys := xorKeysRegex.FindStringSubmatch(res)
xorKey1, _ := strconv.Atoi(string(xorKeys[1]))
xorKey2, err := strconv.Atoi(string(xorKeys[2]))
if err != nil {
log.Errorln("fetchKakaoDetailsFromShareLink: failed to parse XOR Keys!", err)
return "", "", errors.New("error fetchKakaoDetailsFromShareLink")
}
eid := strings.Split(split1[1], "?")[0]

eid := fmt.Sprintf("%d", rawEidInt-xorKey1^xorKey2)
log.Debugln("kakao eid is: ", eid)
redirLink, _, err := httpGetWithRedirLink(link)
if err != nil {
Expand Down