Welcome to the Club Penguin Wiki! Log in or Create an account to join the community!
User:Kawkeetcp/Catalog Items Generator
The following is a script I wrote in Python 3.4 that can be used for generating content for the Penguin Style and Furniture & Igloo Catalog pages. However, understand that the current values for the page ranges are specific to the February 2016 Penguin Style and Furniture & Igloo Catalog (since that was when I coded this) and will likely need to be changed for other months. Section names are also subject to change.
If you are only interested in generating items for certain sections (such as "This Month's Fashions"), you only need to worry about changing the page ranges for those sections. Make sure to then only copy those sections from the output text file. For the other item sections, you can just copy them from the previous catalog pages on the wiki, assuming that the items are the same.
If you don't feel like logging in and counting the pages to determine the page numbers, there is a script here that downloads all of the pages and numbers them. You may also have to change some item names that the script generates, as they aren't always consistent with the names of item articles and images on the wiki. Regardless, it's much faster than going through the catalog and manually typing each item name.
Code
# Description: Generates items from Penguin Style or Furniture & Igloo Catalog
# Author: Hey.youcp
# Date: February 13, 2016 / February 19, 2016
import urllib.request
import json
import webbrowser
# Set month and catalog ("penstyle" = Penguin Style, "iglooedit" = Furniture & Igloo Catalog)
month = "February"
catalog = "penstyle"
# Set section titles and page ranges to search for items (cover page is counted as page 0)
if catalog == "penstyle":
sectionList = [
("Colors",[2,2]),("Items for Everyone",[4,4]),("This Month's Fashions",[6,16]),("Last Month's Fashions",[17,32]),("Get the Look!",[34,34]),
("Penguins at Work",[35,35]),("=Items for Everyone=",[37,38]),("=Head Items=",[39,46]),("=Face Items=",[47,50]),("=Neck Items=",[51,56]),
("=Body Items=",[57,64]),("=Hand Items=",[65,70]),("=Feet Items=",[71,74]),("Backgrounds",[75,76]),("Flags",[77,78])
]
elif catalog == "iglooedit":
sectionList = [
(month + "'s Featured Furniture",[3,6]),("Last Month's Featured Furniture",[7,10]),(month + "'s Featured Igloos",[11,14]),
("Last Month's Featured Igloos",[15,18]),("Igloo Flooring",[19,19]),("=Items for Everyone=",[21,22]),("=Wall Items=",[23,36]),
("=Floor Items=",[37,40]),("=Room Items=",[41,54]),("Essential Igloos",[55,62]),("Igloo Locations",[63,73])
]
else:
sectionList = []
# Initialize empty lists and item counter
itemLists = [[] for i in range(len(sectionList))]
itemCount = 0
# Set link to catalog JSON
catalogLink = "http://media8.clubpenguin.com/mobile/cp-mobile-ui/clubpenguin_v1_6/en_US/deploy/metaplace/devicepng/config/catalog/" + catalog + ".json"
# Download JSON file
isFound = False
try:
urllib.request.urlretrieve(catalogLink,catalog + ".json")
print("JSON file found. Now processing items...")
isFound = True
except:
print("JSON file not found.")
if isFound:
# Read catalog JSON
with open(catalog + ".json","r") as catalogJSON:
content = json.loads(catalogJSON.read())
components = content["components"]
# Search catalog JSON
for i in range(1,len(components)-1):
if "frames" in components[i]["layout"]:
for j in range(0,len(components[i]["layout"]["frames"])):
itemName = components[i]["layout"]["frames"][j]["name"]
# Add items to lists
page = int(components[i]["name"].replace(catalog + "_page",""))
for listIndex in range(0,len(sectionList)):
if page >= sectionList[listIndex][1][0] and page <= sectionList[listIndex][1][1]:
if itemName not in itemLists[listIndex]:
itemLists[listIndex].append(itemName)
itemCount += 1
# Output items
with open("output.txt","w") as output:
for i in range(0,len(itemLists)):
if i == 6 and catalog == "penstyle":
output.write("===Essential Items===\n")
elif i == 5 and catalog == "iglooedit":
output.write("===Igloo Essentials===\n")
output.write("===" + sectionList[i][0] + "===\n<gallery>\n")
for j in range(0,len(itemLists[i])):
item = itemLists[i][j]
output.write(item.replace(" ","") + ".png|[[" + item + "]]\n")
output.write("</gallery>\n\n")
# Print item count and open output text file
print("Done. " + str(itemCount) + " items were processed.")
webbrowser.open("output.txt")