File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,19 +118,17 @@ def parse(self, json_obj: JsonObj) -> "Page":
118118 """Goes through everything in the page, and gets the title and adds all the rows
119119 to the categories field :param json_obj: The json to be parsed :return: A copy
120120 of the Page that you can use to browse all the items."""
121- self .title = json_obj ["title" ]
122121 self .categories = []
123- for row in json_obj ["rows" ]:
124- page_item = self .page_category .parse (row ["modules" ][0 ])
125- self .categories .append (page_item )
126-
127- return copy .copy (self )
128122
129- def parseV2 (self , json_obj : JsonObj ) -> "Page" :
130- self .categories = []
131- for item in json_obj ["items" ]:
132- page_item = self .page_category_v2 .parse (item )
133- self .categories .append (page_item )
123+ if json_obj .get ("rows" ):
124+ self .title = json_obj ["title" ]
125+ for row in json_obj ["rows" ]:
126+ page_item = self .page_category .parse (row ["modules" ][0 ])
127+ self .categories .append (page_item )
128+ else :
129+ for item in json_obj ["items" ]:
130+ page_item = self .page_category_v2 .parse (item )
131+ self .categories .append (page_item )
134132
135133 return copy .copy (self )
136134
You can’t perform that action at this time.
0 commit comments