-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from andjos/char-filter
add char filter function
- Loading branch information
Showing
3 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package m3u | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
func generalParser(value string) string { | ||
if strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`) { | ||
value = strings.Trim(value, `"`) | ||
} | ||
|
||
return value | ||
} | ||
|
||
func tvgNameParser(value string) string { | ||
substrFilter := os.Getenv("TITLE_SUBSTR_FILTER") | ||
// Apply character filter | ||
if substrFilter != "" { | ||
re, err := regexp.Compile(substrFilter) | ||
if err != nil { | ||
log.Println("Error compiling character filter regex:", err) | ||
} else { | ||
value = re.ReplaceAllString(value, "") | ||
} | ||
} | ||
|
||
return generalParser(value) | ||
} | ||
|
||
func tvgIdParser(value string) string { | ||
return generalParser(value) | ||
} | ||
|
||
func groupTitleParser(value string) string { | ||
return generalParser(value) | ||
} | ||
|
||
func tvgLogoParser(value string) string { | ||
return generalParser(value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters