HomeContentSubmit
Home > Mars Explorer > Content > Community > Creations > Document: Marsxplr.com Update Notification (Update: Working again?)
Marsxplr.com Update Notification (Update: Working again?)
8 Comments - 21739 Views
Only for Windows, kinda ;( Sorry ;( (Apparently wget works again?!?)
Submitted By AppleSky on 11/09/14
Mars Explorer, AppleSky, Community, Creations 
This Document originally posted in the "Mars Explorer" Group

Apparently, wget works again, so this works again. Attention Windows users, if you can, please test this out and see if it works for you too! Here is the link to the project.
 
-AppleSky
 
Original Post
 
Why, hai there everybody! 'While back (Talkin' waaaaaaaay 'while back) I created a growl notification system for marsxplr.com for the mods. It's written in batch, which is pretty much a text file with lots of command-line instructions in it that are executed in order, however, batch is for Windows only. I also set out to create a Mac version, unfortuntately, not all of the program could be sucessfully translated over to a Mac/Linux shell script and I didn't have the time to put into a complete rewrite from the ground up ;( And even more unfortunately, wget (the GNU tool used to retrieve copes of the content page for comparison in the program) is no longer able to retrieve the content page of marsxplr. It still works for non-plexpedia sites, and used to work on plexpedia ones as well, but sadly, no longer. As such, this is all pretty much worthless, however; I felt I should make everything available for others to use and do with as they please. If you fix it, congrats! If you adapt it to another project, also congrats! Now, I'm going to start in on the technical descriptions of some of the file, for those interested in manipulating this however they please. If you'd like to learn more about batch scripting, you'll be happy to know that you learn the same way I did, here. Now, on to the code :P
 
If you'd like to follow along with the code as I run through this, download the file from the link at the bottom, extract the archive, right-click on the .bat file and choose edit.
 
Section 1: STARTUP
Here are the lines that figure out whether it should use the 64-bit or 32-bit tools and also grabs the location of your growl installation. It also sets up the tmp folder and checks for the pref folder. If it hits an error, you're directly sent to the ERROR notice at the end of the file. If there's no pref directory, it directs you to the firstrun setup.
 
Section 2: LOADPREF
This loads the saved delay times and on/off times from the pref file into variable. Variable aren't saved between program runs, so this must be done everytime. After loading all the preferences, you are redirected to getting the first sample.
 
Section 3: FIRSTRUN
Here's where all the crazy "Hey, you, user person, whatchu' wantin' to be doin'?" goes on. First, some redundancy checks on the pref folder, just in case. Next, we ask what the user wants their delay time to be. It must be divisible by 30, because the delay that is called later is run in multiples of thirty to allow for everything else and stuff, I think, again, wrote this a looong time ago :P
 
Section 4: FIRSTSAMPLE
Once all the preferences are loaded up, the program is ready to grab it's first sample for comparison. Each time it grabs a sample, it runs a wget command to get the page's source, searches for the lines containing "Replies" and sticks that in a separate file. Afterwards, it generates an MD5 sum for easy comparison. Next, we drop into the main loop at NEWSAMPLE.
 
Section 5: NEWSAMPLE
First off, each time we start the run we're going to remove the old 2nd sample, and also check for to see if it's in the optonially specificed "down time" the user could have set. If it's not, it calls the DELAY section.
 
Section 6: DELAYRET(URN)
After running a delay, it comes back here. This is where it actually gets the second sample file for comparison and then compares it. The 2nd sample is retrieved the exact same way as the first sample. Next, it comapres the two MD5 sums, and depending on the value returned "ERRORLEVEL" it will either throw out an error, start the cycle over at NEWSAMPLE, or go to the UPDATE section.
 
Section 7: UPDATE
Here is where we go if there's been an update to the site. First, we remove the original 1st sample and replace it with our newest, current sample. Afterwards, we send a message to the growl service that there's been an update, to let you know. We run this command through grep to make sure that the message is sent successfully. If it's not, the user is directed to the ERROR section because they do not have growl running. Afterwards, we head back to NEWSAMPLE and continue the loop.
 
Section 8: ONOFFCHECK
This section is called periodically throughout the cycle if the user has specified a period of time that they do not want to check for updates. It comapres the current time to see if it is should be stopping the cycle. If so, it redirects to the ONOFFROU section, otherwise it goes to the DELAY section, back with the main loop.
 
Section 9: DELAY
First off, we check to see if we've run the proper number of delays (delay time / 30). If so, we reset the counter to 0 and go through the list one last time. The ping command is used on the localhost (computer) with a count of 30. This count ends up being approx. 30 seconds for a delay. Next, we increase the delay counter and if we've run the correct amount, we are sent to DELAYRET, to continue the loop, otherwise, we run the ONOFFCHECK or repeat the DELAY call.
 
Section 10: ONOFFROU
This is the loop that is run the entire time the program is inbetween the times the user specified not to look for updates, if he/she set one. It is nearly identical to the ONOFFCHECK section, except we are comparing the current time with the time we should be coming back online, as well as a 50 second delay call.
 
Section 11: ERROR
Hopefully, the user will never have to see this, but if they do, they are provided with a quick list of things that may have gone wrong.
 
And that's everything for that. If you'd like to know the command that no longer works, it is:
 
..\bin\wget -q http://marsxplr.com/browse
Everything else should work just fine, and if you want to be able to use this on another site, replace the URL with your other site, as well as the keyword(s) when you search the file for a specific line, and also the growl notification so the update makes sense.
 
If you're looking to fix this, search for an alternative to the wget command and work on replacing this line. I would, but I have no time nor much interest to devote to this project any longer, and I felt I should leave it open for anyone to look at if they were interested. If you have any questions, please feel free to contact me here. And also, here is the link to the project, enjoy, and sorry that it doesn't work any more ;(
 
-AppleSky
 
P.S. If you are interested in the many many random files I have when I was working on a Mac version, let me know and I'll try to round them up for you.

>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/15 - 22:06 GMT
(In Reply to Item)
It's no big deal that it's for windows because I've got windows

>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/15 - 22:07 GMT << In Reply to
I think its for the people who are good at scripting/coding...
>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/15 - 22:10 GMT << In Reply to
I have windows too but apple im confused, what is it that ur talking about cause im confused and don't know what it is?!?!?!
>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/15 - 23:24 GMT
(In Reply to Item)
Um apple...could you dumb all that down for some of us :P
>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/16 - 0:11 GMT
(In Reply to Item)
Basically, it's for those who are interested in coding, since it doesn't work anymore. The download link is at the end of the article if you wanna just try running it. The README file is in that download, I think.
>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/16 - 0:25 GMT << In Reply to
ah ok thanks. :)
>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/17 - 0:19 GMT
(In Reply to Item)
ok
>> Reply
Array Re: Marsxplr.com Update Notification
2011/09/17 - 3:29 GMT
(In Reply to Item)
FC, stand up.
 
Pity you couldn't get this to work... this had potential. :/


GenTime: 0.0185 seconds

Site Design and Graphics Copyright 2002 - 2019 by Aubrey
Use of this site constitutes agreement to our » Legal Stuff