more progress on convert()
This commit is contained in:
@ -503,7 +503,7 @@ https://rule34.xxx/index.php?page=post&s=list&tags=fridge_%28artist%29
|
|||||||
https://rule34.xxx/index.php?page=post&s=list&tags=frikulu
|
https://rule34.xxx/index.php?page=post&s=list&tags=frikulu
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=frolich
|
https://rule34.xxx/index.php?page=post&s=list&tags=frolich
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=fu_tea
|
https://rule34.xxx/index.php?page=post&s=list&tags=fu_tea
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=fuji_(rua-258)
|
https://rule34.xxx/index.php?page=post&s=list&tags=fuji_%28rua-258%29
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=fuji_yoshida
|
https://rule34.xxx/index.php?page=post&s=list&tags=fuji_yoshida
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=fullkura
|
https://rule34.xxx/index.php?page=post&s=list&tags=fullkura
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=fullmetaldude
|
https://rule34.xxx/index.php?page=post&s=list&tags=fullmetaldude
|
||||||
@ -867,7 +867,7 @@ https://rule34.xxx/index.php?page=post&s=list&tags=kukumomo
|
|||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kumasan_%28kumazonjp%29
|
https://rule34.xxx/index.php?page=post&s=list&tags=kumasan_%28kumazonjp%29
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kumo_no_mae
|
https://rule34.xxx/index.php?page=post&s=list&tags=kumo_no_mae
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kuon_bb
|
https://rule34.xxx/index.php?page=post&s=list&tags=kuon_bb
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kuon_bb_%28kuonr18%2fepijbp%29
|
https://rule34.xxx/index.php?page=post&s=list&tags=kuon_bb_%28kuonr18%2Fepijbp%29
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kuragari
|
https://rule34.xxx/index.php?page=post&s=list&tags=kuragari
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kurenai_yuuji
|
https://rule34.xxx/index.php?page=post&s=list&tags=kurenai_yuuji
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=kurodahlia18
|
https://rule34.xxx/index.php?page=post&s=list&tags=kurodahlia18
|
||||||
@ -1042,7 +1042,7 @@ https://rule34.xxx/index.php?page=post&s=list&tags=mi_nomi_ni
|
|||||||
https://rule34.xxx/index.php?page=post&s=list&tags=miandodi
|
https://rule34.xxx/index.php?page=post&s=list&tags=miandodi
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=miaoshaquan
|
https://rule34.xxx/index.php?page=post&s=list&tags=miaoshaquan
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=micchan_%28ohisashiburi%29
|
https://rule34.xxx/index.php?page=post&s=list&tags=micchan_%28ohisashiburi%29
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=midnight_(midnightstream3)
|
https://rule34.xxx/index.php?page=post&s=list&tags=midnight_%28midnightstream3%29
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=mightyniku
|
https://rule34.xxx/index.php?page=post&s=list&tags=mightyniku
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=miginohito_mitsuru
|
https://rule34.xxx/index.php?page=post&s=list&tags=miginohito_mitsuru
|
||||||
https://rule34.xxx/index.php?page=post&s=list&tags=mihua_mh
|
https://rule34.xxx/index.php?page=post&s=list&tags=mihua_mh
|
||||||
|
44
main.go
44
main.go
@ -98,20 +98,46 @@ func getArtistFromUrl(Url string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func convert(fileLine string) error {
|
func convert(fileLine string) error {
|
||||||
log.Println(fileLine)
|
//log.Println(fileLine)
|
||||||
|
|
||||||
|
artist := getArtistFromUrl(fileLine)
|
||||||
|
oldPath := fmt.Sprintf("Artists/%s", artist)
|
||||||
|
|
||||||
|
// we can look for specific strings like encoded chars and then remove them
|
||||||
|
disallowedStrings := []string{
|
||||||
|
"%20", "%21", "%22", "%23", "%24",
|
||||||
|
"%26","%27", "%28", "%29", "%2A",
|
||||||
|
"%2C", "%2E", "%2F", "%3B", "%3C",
|
||||||
|
"%3E", "%3F", "%5B", "%5C", "%5D",
|
||||||
|
"%5E", "%60", "%7B", "%7C", "%7D",
|
||||||
|
"%7E", "artist",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, disallowedString := range disallowedStrings {
|
||||||
|
fileLine = strings.ReplaceAll(fileLine, disallowedString, "")
|
||||||
|
}
|
||||||
|
fileLine = strings.TrimRight(fileLine, "-_")
|
||||||
|
|
||||||
|
//log.Println(fileLine)
|
||||||
|
|
||||||
if strings.Contains(fileLine, "%") {
|
if strings.Contains(fileLine, "%") {
|
||||||
// we can look for specific encoded chars and the remove them and continue instead of returning an error
|
|
||||||
return fmt.Errorf("%s", "URL contains Encoded Unicode and a direct conversion cannot be reasonably made")
|
return fmt.Errorf("%s", "URL contains Encoded Unicode and a direct conversion cannot be reasonably made")
|
||||||
}
|
}
|
||||||
artist := getArtistFromUrl(fileLine)
|
|
||||||
log.Println("artist:", artist)
|
|
||||||
//path := fmt.Sprintf("Artists/%s", artist)
|
|
||||||
//log.Println("path:", path)
|
|
||||||
|
|
||||||
if strings.ContainsAny(artist, "!\"#$&'()*,;<>?[\\]^`{|}~") {
|
artist = getArtistFromUrl(fileLine)
|
||||||
return fmt.Errorf("%s", "artistName contains disallowed characters and a direct conversion cannot be reasonably made")
|
//log.Println("artist:", artist)
|
||||||
|
newPath := fmt.Sprintf("Artists/%s", artist)
|
||||||
|
|
||||||
|
if len(artist) <= 1 {
|
||||||
|
return fmt.Errorf("%s", "Trying to remove unwanted stuff from artistName has caused it to become too small")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Compare(oldPath, newPath) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//log.Printf("oldPath: %s\tnewPath: %s\n", oldPath, newPath)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +158,7 @@ func parseLinks(filename string) error {
|
|||||||
if !strings.Contains(line, "#") {
|
if !strings.Contains(line, "#") {
|
||||||
err = convert(line)
|
err = convert(line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error: %s\n", err)
|
log.Printf("convert: %s\n", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user