Commit 6fe1417d1c

6fe1417d1c234bff44aa5cf57d7f090178351960

parent: 0a219a584c

Unsigned

Wraient <wraient.911@gmail.com> · 2025-09-22 15:50 UTC

add: update encoding mapping

Layout: unified · split

internal/episode_url.go +44 −5
@@ -35,11 +35,23 @@ func decodeProviderID(encoded string) string {
35 35
36 // Mapping for the replacements 36 // Mapping for the replacements
37 replacements := map[string]string{ 37 replacements := map[string]string{
38 "01": "9", "08": "0", "05": "=", "0a": "2", "0b": "3", "0c": "4", "07": "?", 38 // Uppercase letters
39 "00": "8", "5c": "d", "0f": "7", "5e": "f", "17": "/", "54": "l", "09": "1", 39 "79": "A", "7a": "B", "7b": "C", "7c": "D", "7d": "E", "7e": "F", "7f": "G",
40 "48": "p", "4f": "w", "0e": "6", "5b": "c", "5d": "e", "0d": "5", "53": "k", 40 "70": "H", "71": "I", "72": "J", "73": "K", "74": "L", "75": "M", "76": "N", "77": "O",
41 "1e": "&", "5a": "b", "59": "a", "4a": "r", "4c": "t", "4e": "v", "57": "o", 41 "68": "P", "69": "Q", "6a": "R", "6b": "S", "6c": "T", "6d": "U", "6e": "V", "6f": "W",
42 "51": "i", 42 "60": "X", "61": "Y", "62": "Z",
43 // Lowercase letters
44 "59": "a", "5a": "b", "5b": "c", "5c": "d", "5d": "e", "5e": "f", "5f": "g",
45 "50": "h", "51": "i", "52": "j", "53": "k", "54": "l", "55": "m", "56": "n", "57": "o",
46 "48": "p", "49": "q", "4a": "r", "4b": "s", "4c": "t", "4d": "u", "4e": "v", "4f": "w",
47 "40": "x", "41": "y", "42": "z",
48 // Numbers
49 "08": "0", "09": "1", "0a": "2", "0b": "3", "0c": "4", "0d": "5", "0e": "6", "0f": "7",
50 "00": "8", "01": "9",
51 // Special characters
52 "15": "-", "16": ".", "67": "_", "46": "~", "02": ":", "17": "/", "07": "?", "1b": "#",
53 "63": "[", "65": "]", "78": "@", "19": "!", "1c": "$", "1e": "&", "10": "(", "11": ")",
54 "12": "*", "13": "+", "14": ",", "03": ";", "05": "=", "1d": "%",
43 } 55 }
44 56
45 // Perform the replacement equivalent to sed 's/^../.../' 57 // Perform the replacement equivalent to sed 's/^../.../'
@@ -60,6 +72,33 @@ func decodeProviderID(encoded string) string {
60} 72}
61 73
62func extractLinks(provider_id string) map[string]interface{} { 74func extractLinks(provider_id string) map[string]interface{} {
75 // Check if provider_id is already a full URL (external link)
76 if strings.HasPrefix(provider_id, "http://") || strings.HasPrefix(provider_id, "https://") {
77 // It's an external direct video link, return it as-is
78 cleanedURL := provider_id
79 // Clean up any double slashes in the URL (except after protocol)
80 if strings.Contains(cleanedURL, "://") {
81 parts := strings.SplitN(cleanedURL, "://", 2)
82 if len(parts) == 2 {
83 protocol := parts[0]
84 rest := parts[1]
85 // Replace any double slashes in the rest of the URL
86 rest = strings.ReplaceAll(rest, "//", "/")
87 cleanedURL = protocol + "://" + rest
88 }
89 }
90
91 Log(fmt.Sprintf("Direct external link detected: %s -> %s", provider_id, cleanedURL))
92 return map[string]interface{}{
93 "links": []interface{}{
94 map[string]interface{}{
95 "link": cleanedURL,
96 },
97 },
98 }
99 }
100
101 // It's a relative path for allanime API
63 allanime_base := "https://allanime.day" 102 allanime_base := "https://allanime.day"
64 url := allanime_base + provider_id 103 url := allanime_base + provider_id
65 client := &http.Client{} 104 client := &http.Client{}