Welcome to Rile5.com
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing topics, give reputation to other members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Sign in to follow this  
Followers 0

[THREADING!]Fastest(?) Item downloader [Python]

19 posts in this topic

Posted · Report post

I wrote this in my spare time, but it's currently the fastest downloader(I think) for CP items, that exists.

 

Why would I use that?

Threading. This project uses threads for downloading, meaning you will download with 3 times(or less) the speed. It will definitely be faster!

 

Why isn't it an exe?

Because fuck exe's. Also, compiler plain out refused to compile my shit.

 

Screenshot?

c1cv.png

How do I use it?

Install python 3.3(or higher). Create a folder(say items), and create these subfolders:

items/sprites

items/paper

items/icons

 

Create a file, call it run.py(or something ending with py)

items/run.py

 

Run run.py, and wait. It should be done fairy quickly.

 

Code?:

Code:

import threading
import json
import urllib.request
def downloadFile(url):
	return urllib.request.urlopen(url).read()
def saveFile(content,location):
	fileStream=open(location,'wb')
	fileStream.write(content)
def downloadItems(type):
	print("Downloading:"+type)
	json_text=downloadFile("http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json").decode("utf-8")
	decoded=json.loads(json_text)
	for item in decoded:
		try:
			itemContent=downloadFile("http://media1.clubpenguin.com/play/v2/content/global/clothing/"+type+"/"+str(item['paper_item_id'])+".swf")
		except urllib.error.HTTPError:
			if type=="paper": #We want it output only once.
				print("Item "+str(item['paper_item_id'])+" is non-existent, skipping")
			itemContent="Fake&Gay"
		if itemContent!="Fake&Gay":
			saveFile(itemContent,type+"/"+str(item['paper_item_id'])+".swf")
			if type=="sprites": #Photos might be sad
				print("Downloaded item: "+str(item['paper_item_id']))
	
	print(type+" are DONE!")
sprites=threading.Thread(target=downloadItems,args=("sprites",))
paper=threading.Thread(target=downloadItems,args=("paper",))
icons=threading.Thread(target=downloadItems,args=("icons",))
print("""
Club Penguin Items Downloader
By albertvision
Made specifically for rile5!
""")
sprites.start()
paper.start()
icons.start()
5 people like this

Share this post


Link to post
Share on other sites

Posted · Report post

Nice, but where will it save the items?

Share this post


Link to post
Share on other sites

Posted · Report post

Nice, but where will it save the items?

In the folders: sprites, icons and paper.

Great job albertvision! That's awesome!

2 people like this

Share this post


Link to post
Share on other sites

Posted · Report post

Nice, but where will it save the items?

In the current folder, in the example above items/

Share this post


Link to post
Share on other sites

Posted · Report post

newpath = r'sprites' 
if not os.path.exists(newpath): os.makedirs(newpath)

 

newpath = r'icons' 
if not os.path.exists(newpath): os.makedirs(newpath)

 

newpath = r'paper' 
if not os.path.exists(newpath): os.makedirs(newpath)

 

Nice script btw!

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Its the fastest? Dosen't it depend on the speed of your internet? Or does this make a difference to the speed it goes to the item and saves it? Oh well, thanks for releasing.

Share this post


Link to post
Share on other sites

Posted · Report post

Its the fastest? Dosen't it depend on the speed of your internet? Or does this make a difference to the speed it goes to the item and saves it? Oh well, thanks for releasing.

It still depends on your internet speed, but instead of downloading one file, you download 3 at once.

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Would it download faster on a vps? and how do you install python on a vps?

Share this post


Link to post
Share on other sites

Posted · Report post

Would it download faster on a vps? and how do you install python on a vps?

What OS are you running the VPS on?

Share this post


Link to post
Share on other sites

Posted · Report post

Ubuntu 12.04 its only a crappy host1free, but i'm only using to to create an iCPPS server(bored of opencp)

Share this post


Link to post
Share on other sites

Posted · Report post

Looks a lot better then mine. 

Share this post


Link to post
Share on other sites

Posted · Report post

Ubuntu 12.04 its only a crappy host1free, but i'm only using to to create an iCPPS server(bored of opencp)

sudo apt-get install python3.3 or something similar.

 

Looks a lot better then mine. 

Suure... I totally have a design, and not just an output. Is your threaded?

Share this post


Link to post
Share on other sites

Posted · Report post

sudo apt-get install python3.3 or something similar.

 

Suure... I totally have a design, and not just an output. Is your threaded?

 

Mines ugly as hell... jk, jk. It is threaded.

Share this post


Link to post
Share on other sites

Posted · Report post

Mines ugly as hell... jk, jk. It is threaded.

Well, mine is...

mine is...

mine is...

I FIGURED IT OUT!

Cross-platform. Heeh, Heeh.

2 people like this

Share this post


Link to post
Share on other sites

Posted · Report post

You made a little mistake / forgot to add it. The code you posted just downloads the paper swfs for everything.

Change this line:

ItemContent=downloadFile("http://media1.clubpenguin.com/play/v2/content/global/clothing/paper/"+str(item['paper_item_id'])+".swf")

to

ItemContent=downloadFile("http://media1.clubpenguin.com/play/v2/content/global/clothing/"+type+"/"+str(item['paper_item_id'])+".swf")
2 people like this

Share this post


Link to post
Share on other sites

Posted · Report post

 

You made a little mistake / forgot to add it. The code you posted just downloads the paper swfs for everything.

Change this line:

ItemContent=downloadFile("http://media1.clubpenguin.com/play/v2/content/global/clothing/paper/"+str(item['paper_item_id'])+".swf")

to

ItemContent=downloadFile("http://media1.clubpenguin.com/play/v2/content/global/clothing/"+type+"/"+str(item['paper_item_id'])+".swf")

Thanks! I missed that one :(

Share this post


Link to post
Share on other sites

Posted · Report post

Looks a lot better then mine. 

Is that sarcastic? if its not, Your is way better still.

Share this post


Link to post
Share on other sites

Posted · Report post

Is that sarcastic? if its not, Your is way better still.

He was sarcastic about the looks, because mine is just a shell, but mine is multi platform and doesn't have to care about showing a GUI, so it might be a tiny bit faster

Share this post


Link to post
Share on other sites

Posted · Report post

shit + threading = BEST SHIT EVER

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0