-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add YouTube channel tooltip support (#157)
Co-authored-by: zneix <zneix@zneix.eu> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
- Loading branch information
1 parent
ff9ad41
commit 9844c07
Showing
7 changed files
with
292 additions
and
8 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,39 @@ | ||
package youtube | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type channelID struct { | ||
ID string | ||
chanType channelType | ||
} | ||
|
||
// Gets the channel type from a cache key type segment - used to identify what YouTube API to use | ||
func getChannelTypeFromString(channelType string) channelType { | ||
switch channelType { | ||
case "c": | ||
return CustomChannel | ||
case "user": | ||
return UserChannel | ||
case "channel": | ||
return IdentifierChannel | ||
} | ||
|
||
return InvalidChannel | ||
} | ||
|
||
func constructCacheKeyFromChannelID(ID channelID) string { | ||
return string(ID.chanType) + ":" + ID.ID | ||
} | ||
|
||
func deconstructChannelIDFromCacheKey(cacheKey string) channelID { | ||
splitKey := strings.Split(cacheKey, ":") | ||
|
||
if len(splitKey) < 2 { | ||
return channelID{ID: "", chanType: InvalidChannel} | ||
} | ||
|
||
return channelID{ID: splitKey[1], chanType: getChannelTypeFromString(splitKey[0])} | ||
} | ||
|
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
Oops, something went wrong.