-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#49 Create TagManager module for enhanced RSPL tag handling
Introduce the TagManager class to manage RSPL tags systematically, fetching different tag categories from RSPlaylist. Refactor RSPL tag structures in the configuration to improve consistency and simplify tag initialization. Prepare integration points for future tag validation and user-based customizations.
- Loading branch information
Showing
6 changed files
with
98 additions
and
17 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
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,21 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class RSPLTag: | ||
name: str | ||
rspl_id: str | ||
icon: str | ||
color: str | ||
user: bool | ||
|
||
|
||
@dataclass | ||
class RSPLTags: | ||
tag_to_download: RSPLTag | ||
tag_downloaded: RSPLTag | ||
tag_loaded: RSPLTag | ||
tag_new_viewer_request: RSPLTag | ||
tag_raider_request: RSPLTag | ||
tag_vip_viewer_request: RSPLTag | ||
|
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,51 @@ | ||
import logging | ||
|
||
from dacite import from_dict | ||
|
||
from config.config_data import ConfigData | ||
from modules.servant.song_loader.rs_playlist_data import RsPlaylist | ||
from modules.servant.song_loader.song_loader import SongLoader | ||
from utils.rs_playlist_util import get_playlist | ||
|
||
log = logging.getLogger() | ||
|
||
|
||
class TagManager: | ||
def __init__(self, config_data: ConfigData, song_loader: SongLoader): | ||
# TODO | ||
# TODO | ||
# TODO | ||
rsplaylist = self.get_rsplaylist(config_data) | ||
self.all_tags = self.__fetch_all_tags(rsplaylist) | ||
self.user_tags = self.__fetch_user_tags(rsplaylist) | ||
self.server_tags = self.__fetch_server_tags(rsplaylist) | ||
|
||
pass | ||
|
||
@staticmethod | ||
def get_rsplaylist(config_data): | ||
loader = config_data.song_loader | ||
new_playlist = get_playlist(loader.twitch_channel, loader.phpsessid) | ||
rsplaylist = from_dict(data_class=RsPlaylist, data=new_playlist) | ||
return rsplaylist | ||
|
||
@staticmethod | ||
def __fetch_all_tags(rsplaylist): | ||
return {value.name: key for key, value in rsplaylist.channel_tags.items()} | ||
|
||
@staticmethod | ||
def __fetch_server_tags(rsplaylist): | ||
return {value.name: key for key, value in rsplaylist.channel_tags.items() if not value.user} | ||
|
||
@staticmethod | ||
def __fetch_user_tags(rsplaylist): | ||
return {value.name: key for key, value in rsplaylist.channel_tags.items() if value.user} | ||
|
||
# def update_tags(self, new_playlist): | ||
# self.rsplaylist_json = new_playlist | ||
# self.rsplaylist = from_dict(data_class=RsPlaylist, data=new_playlist) | ||
# | ||
# def __log_available_rspl_tags(self): | ||
# tags = self.rsplaylist.channel_tags | ||
# user_tags = {value.name: key for key, value in tags.items() if value.user} | ||
# log.warning("Tags set in RSPlaylist:\n%s", pprint.pformat(user_tags)) |