@@ -17,7 +17,8 @@ def __init__(self, link: str):
1717 f"https://www.gcores.com/gapi/v1/games/{ self .id } ?include="
1818 "tags%2Cuser%2Cgame-stores%2Cgame-links%2Cinvolvements.entity.user%2Cactive-entry-vote-activities%2Cactive-entry-vote-activities.vote-activity-options%2Cactive-entry-vote-activity-records%2Cactive-entry-vote-activity-records.vote-activity-option&fields[users]=nickname%2Cthumb&fields[involvements]=position%2Ctitle%2Crank%2Centity&fields[celebrities]=user&fields[organizations]=name&fields[tags]=name%2Ctag-type&meta[tags]=%2C&meta[users]=%2C&meta[celebrities]=%2C&meta[organizations]=%2C"
1919 )
20- print (self .get_authors ())
20+ self .tags = self .get_tags ()
21+ logger .warning (self .tags )
2122
2223 def get_name (self ) -> str :
2324 return self .parser (".data.attributes.title" )
@@ -37,8 +38,8 @@ def get_authors(self) -> list[dict]:
3738 "文案" : "screenwriter" ,
3839 "美术" : "artist" ,
3940 "动画" : "animation" ,
40- "制作" : "developer " ,
41- "开发" : "developer " ,
41+ "制作" : "producer " ,
42+ "开发" : "producer " ,
4243 "音乐" : "musician" ,
4344 "音效" : "musician" ,
4445 "场景" : "scenographer" ,
@@ -104,31 +105,56 @@ def parse_role(role: str | list):
104105 ret .append (
105106 {
106107 "name" : self .parser ('.data.attributes."booom-group-title"' ),
107- "role" : "producer" ,
108+ "role" : [ "producer" ] ,
108109 }
109110 )
110111 return ret
111112
112- def get_tags (self ) -> list [dict ]:
113- pass
113+ def get_tags (self ) -> list [str ]:
114+ return self .parser (
115+ '.included.[] | select(.type == "tags").attributes.name' , method = "all"
116+ )
114117
115118 def get_misc_tags (self ) -> list [dict ]:
116- pass
119+ return []
117120
118121 def get_platforms (self ) -> list [str ]:
119- pass
122+ repl = {
123+ "Windows" : "windows" ,
124+ }
125+ return [repl [i .strip ()] for i in self .tags if i in repl .keys ()]
120126
121127 def get_langs (self ) -> list [str ]:
122- pass
128+ return [ "zh" ]
123129
124130 def get_links (self ) -> list [dict ]:
125- pass
131+ downlink = self .parser ('.data.attributes."download-link"' )
132+ if downlink :
133+ return [{"name" : ".demo-version" , "uri" : downlink }]
126134
127135 def get_screenshots (self ) -> list [str ]:
128- pass
136+ link : list [str ] = self .parser (".data.attributes.screenshots" )
137+ return ["https://image.gcores.com/" + _ for _ in link ]
129138
130139 def to_yaml (self ) -> YamlData :
131- pass
140+ ret = {
141+ "name" : self .get_name (),
142+ "brief-description" : self .get_brief_desc (),
143+ "description" : self .get_desc (),
144+ "description-format" : "markdown" ,
145+ "authors" : self .get_authors (),
146+ "tags" : {
147+ "type" : [],
148+ "lang" : self .get_langs (),
149+ "platform" : self .get_platforms (),
150+ "publish" : [".website" ],
151+ "misc" : self .get_misc_tags (),
152+ },
153+ "links" : self .get_links (),
154+ "thumbnail" : self .get_thumbnail (),
155+ "screenshots" : self .get_screenshots (),
156+ }
157+ return YamlData (self ._load_hook (ret ))
132158
133159 def parser (self , jq : str , json : dict | str = None , method : str = "first" ):
134160 try :
@@ -138,3 +164,6 @@ def parser(self, jq: str, json: dict | str = None, method: str = "first"):
138164 except Exception as e :
139165 logger .warning (f"Parse /{ jq } / failed!({ e !r} )" )
140166 logger .debug (json )
167+
168+ def get_type_tags (self ) -> list [dict ]:
169+ pass
0 commit comments