-
Notifications
You must be signed in to change notification settings - Fork 91
/
tistory.go
33 lines (29 loc) · 879 Bytes
/
tistory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"net/url"
"strings"
)
// getTistoryUrls downloads tistory URLs
// http://t1.daumcdn.net/cfile/tistory/[…] => http://t1.daumcdn.net/cfile/tistory/[…]
// http://t1.daumcdn.net/cfile/tistory/[…]?original => as is
func getTistoryUrls(link string) (map[string]string, error) {
if !strings.HasSuffix(link, "?original") {
link += "?original"
}
return map[string]string{link: ""}, nil
}
func getLegacyTistoryUrls(link string) (map[string]string, error) {
link = strings.Replace(link, "/image/", "/original/", -1)
return map[string]string{link: ""}, nil
}
func getTistoryWithCDNUrls(urlI string) (map[string]string, error) {
parameters, _ := url.ParseQuery(urlI)
if val, ok := parameters["fname"]; ok {
if len(val) > 0 {
if RegexpUrlTistoryLegacy.MatchString(val[0]) {
return getLegacyTistoryUrls(val[0])
}
}
}
return nil, nil
}