-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: libsyn custom code & data-item JSON processing
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 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
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,22 @@ | ||
package libsyn | ||
|
||
import ( | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
// Goal is to turn https://traffic.libsyn.com/democratieparticipative/DPS09E16.mp3 | ||
// into https://traffic.libsyn.com/secure/force-cdn/highwinds/democratieparticipative/DPS09E16.mp3 | ||
// So it's basically adding /secure/force-cdn/highwinds/ after the domain. | ||
func IsLibsynURL(URL string) bool { | ||
return strings.Contains(URL, "traffic.libsyn.com") && strings.HasSuffix(URL, ".mp3") | ||
} | ||
|
||
func GenerateHighwindsURL(URL string) (*url.URL, error) { | ||
highwindURL, err := url.Parse(strings.Replace(URL, "traffic.libsyn.com", "traffic.libsyn.com/secure/force-cdn/highwinds", 1)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return highwindURL, nil | ||
} |