Raised This Month: $66 Target: $400
 16% 

All Approved AMXX Plugins in one zip - AHK script included


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 06-02-2009 , 19:29   All Approved AMXX Plugins in one zip - AHK script included
Reply With Quote #1

EDIT: Finished AutoHotkey script - Link

What?
This is a zip with all the sma files (1803 files) from the Approved Plugins section as of 2009/06/01 (June 1st 2009).

Why?
Normally, you have to search on the forums for examples of code, and sometimes you can't find a good example.

Now, with a nifty search tool like PowerGREP, you can search through the source code of all approved plugins! This can be very useful as a tool for learning new functions and stuff!

How?
I used AutoHotkey, PowerGREP, and cygwin's wget to complete this little project. I'm in the process of writing coherent instructions to reproduce this project. I might even conglomerate some of my scripts and automate some steps. It can probably be done with AutoHotkey alone, but I ran into a snag, and it certainly can be done by writing a program in a "real" programming language.

It took me a few hours to tweak this and that. I can't guarantee that I got all of the sma files, but I have 1803 sma's, so it's a good start.

The hardest part was dealing with "odd" characters, like spaces and periods at the start or end of folder names, or other characters that didn't behave.

Note:
Do not use this as a "all-in-one" pack to install plugins on your server. Some plugins require additional files like language txt's, models, sprites, sounds, or inc's. This zip does not have any of these files.

Also note that some characters were troublesome and may have been removed or replaced with an underscore ( _ ).

Directory Structure:
Approved AMXX Plugins
Author Name
Plugin Name
plugin.sma
It has been compressed twice to get under the 5.00 MB size limit for zip files. The limit for rar files is set at 9.54 MB for some reason.
Attached Files
File Type: zip Approved AMXX Plugins 20090601.zip (4.91 MB, 482 views)
__________________

Last edited by stupok; 06-04-2009 at 20:12.
stupok is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-02-2009 , 19:31   Re: All Approved AMXX Plugins in one zip
Reply With Quote #2

Lol crazy stuff. Certainly useful.
__________________
joaquimandrade is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 06-02-2009 , 19:34   Re: All Approved AMXX Plugins in one zip
Reply With Quote #3

VIRUSSSSSSSSSSS :O

haha awesome.

u know i just wont to see if my plugin is there, so go to folder One, open catch mod black edition & nothing is there hihi but its realy awesome. GJ & +k+k+k+k+k
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 06-02-2009 , 19:49   Re: All Approved AMXX Plugins in one zip
Reply With Quote #4

I'm feeling so special, my nick is on that file! :O
Nice work.
__________________
"There is no knowledge, that is not power"
fezh is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-02-2009 , 19:56   Re: All Approved AMXX Plugins in one zip
Reply With Quote #5

Nice, sounds like it was a lot of work.

What is the format of directories.txt? I see a lot of "" (xe2)in the file. I think it's probably a space or tab or something that is supposed to go there?
__________________
fysiks is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 06-02-2009 , 20:29   Re: All Approved AMXX Plugins in one zip
Reply With Quote #6

I was supposed to take that out before I zipped it

I needed a good token to separate strings, so I used . Originally, I used commas, but then I found that some users have commas in their names and some people put commas in the plugin names.

I'll try to post the instructions soon, if you're curious.
__________________
stupok is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-02-2009 , 20:33   Re: All Approved AMXX Plugins in one zip
Reply With Quote #7

Waoo, good job.
__________________
Arkshine is offline
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 06-02-2009 , 22:07   Re: All Approved AMXX Plugins in one zip
Reply With Quote #8

lolz alot of time to create that. Much credit

+ Karma (Wait....)
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG
stupok
Veteran Member
Join Date: Feb 2006
Old 06-04-2009 , 16:19   Re: All Approved AMXX Plugins in one zip
Reply With Quote #9

Completing this project was a learning experience for me, so my first attempt was very messy and hard to follow. I don't want to bother trying to explain how I initially approached the problem, so I put all of the steps into one script, and it worked!

If you have AutoHotkey, you can try my script. I welcome suggestions to improve the script. There are some lazy steps and possibly some mistakes.

However, One's plugin was downloaded this time, so I must be doing something right.

I won't post the zips anymore because they are large. If you want to download all of the plugins, you can try running my script. It usually takes ~5-10 minutes to complete.

Code:
;
; Approved AMXX Plugin Downloader
; Language:       English
; Platform:       Win9x/NT
; Author:         stupok <[email protected]>
;
; Script Function:
;	This script downloads all AMXX approved plugins to a folder called "Approved AMXX Plugins" by parsing html code.
;

#NoEnv
#SingleInstance FORCE
SendMode Input
SetWorkingDir %A_ScriptDir%

; number of entries in the approved plugins list
MAXPLUGINS := 1783

; name of main folder
MAINFOLDER := "Approved AMXX Plugins"

; temp file for storing stuff
TEMPFILE = temp.txt

; debug file
POSTIDFILE = postids.ini

; list of approved plugins
URL = http://www.amxmodx.org/compiler.php?mod=1&cat=0&plugin=&author=&go=search

; download the list
ToolTip, Downloading list of approved plugins..., 0, 0
UrlDownloadToFile,%URL%,%TEMPFILE%

; put the list in a variable
FileRead,MYBUFFER,%TEMPFILE%
FileDelete,%TEMPFILE%

; clean up the variable's contents
StringReplace,MYBUFFER,MYBUFFER,`n,,All
StringReplace,MYBUFFER,MYBUFFER,`r,,All

; remove characters that aren't happy in folder names
MYBUFFER := RegExReplace(MYBUFFER,"&[^a][qlg#]?[ut\d]?[o\d]?[t\d]?\d?\d?;?","_")
MYBUFFER := RegExReplace(MYBUFFER,"&am?p?;?","&")
MYBUFFER := RegExReplace(MYBUFFER,"<img src='images/(.*?)\.gif' title=''>","$U1")
MYBUFFER := RegExReplace(MYBUFFER,">\.",">")
MYBUFFER := RegExReplace(MYBUFFER,"\.?\.?\.?<","<")

; parse the list to get post number, name, author, mod, category
REGEX := "<a\shref='http://forums\.alliedmods\.net/showthread\.php\?p=(\d{1,10})'\starget='_blank'>(.{1,35})</a></td>[\s\t\r\n]{1,4}<td>(.*?)</td>[\s\t\r\n]{1,4}<td>(.*?)</td>[\s\t\r\n]{1,4}<td>(.*?)</td>"

; make the main folder
FileCreateDir,%MAINFOLDER%

i := 0
TotalFiles := 0
ETA := 0
FoundPos := 1

while FoundPos != 0
{
	; record starting time
	StartTime := A_TickCount

	FoundPos := RegexMatch(MYBUFFER,REGEX,Match,FoundPos)

	; display errors
	if ErrorLevel
		MsgBox, %ErrorLevel%

	; we found a match
	if FoundPos
	{
		FoundPos += StrLen(Match)

		i++

		; replace wacky characters with an underscore
		Match2 := RegExReplace(Match2,"[^\w\d\s&]","_")
		Match3 := RegExReplace(Match3,"[^\w\d\s&]","_")

		; debug file
		;IniWrite, %Match1%, %POSTIDFILE%, %i%, postid
		;IniWrite, %Match2%, %POSTIDFILE%, %i%, name
		;IniWrite, %Match3%, %POSTIDFILE%, %i%, author
		;IniWrite, %Match4%, %POSTIDFILE%, %i%, mod
		;IniWrite, %Match5%, %POSTIDFILE%, %i%, category

		; make the folder for the plugin
		FileCreateDir,%MAINFOLDER%\%Match3%\%Match2%

		URL = http://forums.alliedmods.net/showpost.php?p=%Match1%&postcount=1

		; download the post and put it in a variable
		UrlDownloadToFile,%URL%,%TEMPFILE%
		FileRead,POSTBUFFER,%TEMPFILE%
		FileDelete,%TEMPFILE%

		; clean up the contents
		StringReplace,POSTBUFFER,POSTBUFFER,`n,,All
		StringReplace,POSTBUFFER,POSTBUFFER,`r,,All

		StartingPosition := 1
	
		while (StartingPosition != 0)
		{
			; look for attachment links
			StartingPosition := RegExMatch(POSTBUFFER,"attachmentid=(\d{1,10}).*?>Get Source</a> \((.*?) -",PluginMatch,StartingPosition)

			if ErrorLevel
				MsgBox, %ErrorLevel%

			; we found a valid attachment
			if StartingPosition
			{
				StartingPosition += StrLen(Match)

				TotalFiles++

				URL = http://forums.alliedmods.net/attachment.php?attachmentid=%PluginMatch1%&d

				; download the plugin to the correct folder
				UrlDownloadToFile,%URL%,%MAINFOLDER%\%Match3%\%Match2%\%PluginMatch2%
			}
		}
	}
	; no more results
	else
	{
		break
	}

	; smooth the estimated time left display
	if(!Mod(i,2))
	{
		ElapsedTime := A_TickCount - StartTime
		if ElapsedTime
			ETA := ((ElapsedTime * (MAXPLUGINS - i)) / 1000) / 60
	}

	ToolTip,Downloading... %i%/%MAXPLUGINS% Time Left: %ETA% minutes`n%Match3%`n%Match2%, 0, 0
}

MsgBox, Finished!`nTotal plugins: %i%`nTotal files: %TotalFiles%
__________________
stupok is offline
xPaw
AMX Mod X Moderator
Join Date: Jul 2008
Old 06-04-2009 , 17:12   Re: All Approved AMXX Plugins in one zip - AHK script included
Reply With Quote #10

Holy fuck.. are you normal?
__________________
xPaw is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:38.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode