03-27-2008, 06:13 PM | #1 |
Member
Posts: 13
Karma: 56
Join Date: Mar 2008
Location: London
Device: iRex iLiad
|
The Guardian 24 automatic download
Hi,
I received my iliad this week and started playing a bit with it... One thing I wanted was to download automatically the 24h pdf edition of the guardian (a UK newspaper), so I wrote a small script that do just that. The script starts a network connection, delete any previous downloaded pdf, download the last online pdf from the guardian website, create a folder for the iliad, a manifest (to show an icon and the date of the download), and the stop the network connection. To install this, download the attached zip, decompress it on your MMC card in newspaper, go in the Guardian24 folder, click on the "Guardian UK" item... and it should just work! (of course you need the shell access for that) If you want to use it elsewhere, you need to edit the run.sh script, and modify the GUARDIAN_PATH variable to point to the location of your choice. Note that adapting the script to any other resource is trivial, so have fun. Here is the script itself: Code:
#!/bin/sh export GUARDIAN_PATH=/media/card/newspapers/Guardian24/ /usr/bin/wired.sh start /usr/bin/wireless.sh start rm -rf $GUARDIAN_PATH/Guardian.pdf mkdir $GUARDIAN_PATH/Guardian.pdf echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><package><metadata><dc-metadata><Title>The Guardian 24h edition</Title><Description>Downloaded: `echo \`date\``</Description></dc-metadata><y-metadata><startpage>Guardian.pdf</startpage><image>icon.png</image><version>000</version></y-metadata></metadata></package>" > $GUARDIAN_PATH/Guardian.pdf/manifest.xml wget -O $GUARDIAN_PATH/Guardian.pdf/Guardian.pdf http://download.guardian.co.uk/g24/World.pdf cp $GUARDIAN_PATH/get-guardian/icon.png $GUARDIAN_PATH/Guardian.pdf/icon.png /usr/bin/wired.sh stop /usr/bin/wireless.sh stop |
03-27-2008, 06:33 PM | #2 |
Guru
Posts: 785
Karma: 100000
Join Date: Dec 2007
Device: Sony PRS-300. PRS-650, PRS-900, iPad2, Iconia A500, Irex Iliad (sold)
|
Well done mate, if there ever was a reason to install shell access on my iLiad, this is it!
|
Advert | |
|
03-27-2008, 09:39 PM | #3 |
Evangelist
Posts: 423
Karma: 2153430
Join Date: Dec 2007
Device: BeBook
|
This is excellent idea, I've been wondering how to download Guardian 24, but lack the programming knowledge...
However, I've given it a go, and there's something not working for me. I changed the path to /media/cf/newspapers/Guardian24/ to suit my iLiad. It seems to go online, and downloads a file with a correct datestamp, but when I try to load the file, the progress bar flashes and then stops with no result. Looking at the file from my linux PC, it shows as an empty file. I've checked my wifi connection, and it's definitely working, I've checked the Guardian 24 file online and it's definitely up, so I don't know what else to try. Any help much appreciated! |
03-27-2008, 10:31 PM | #4 | |
Member
Posts: 13
Karma: 56
Join Date: Mar 2008
Location: London
Device: iRex iLiad
|
Quote:
My guess is that the iliad did not manage to get an internet connection. I only tried with a wired connection, maybe that's a reason (although it should have worked anyway...). Are you sure you configured your network connection on the iliad ? If you open mrxvt and type ifconfig what is shown ? and if you then manualltry try to initiate the internet connection (type "/usr/bin/wired.sh start" or /usr/bin/wireless.sh start) what is displayed ? |
|
03-27-2008, 10:39 PM | #5 |
Junior Member
Posts: 7
Karma: 10
Join Date: Feb 2008
Device: Iliad
|
Hi, I hope I can help, but I just started playing around with wireless access.
I think you might try and specify the ssid and security when using wireless.sh edit the run.sh line to: Code:
$/usr/bin/wireless.sh start [network ssid] [encyrption] [key] |
Advert | |
|
03-28-2008, 09:33 AM | #6 |
Evangelist
Posts: 423
Karma: 2153430
Join Date: Dec 2007
Device: BeBook
|
Afraid I don't have mrxvt installed (unless it comes as standard and I've not found it?). But iNewstand is definitely connecting, so it can't be a bad connection. I'll try adding ksira's line to the script, and if/when I have time, I'll look up mrxvt.
|
03-28-2008, 09:46 AM | #7 |
Evangelist
Posts: 423
Karma: 2153430
Join Date: Dec 2007
Device: BeBook
|
Just tried ksira's line of code, and now it just sits there with the light flashing and the progress bars cycling. Perhaps I got the line wrong. Should it have been:
Code:
$/usr/bin/wireless.sh start mynetwork wep 12345678 Code:
$/usr/bin/wireless.sh start ssid mynetwork encryption wep key 12345678 |
03-28-2008, 10:01 AM | #8 | |
Connoisseur
Posts: 53
Karma: 140
Join Date: Mar 2008
Device: iRex iLiad (v1) / Sony Librie
|
Quote:
/usr/bin/wireless.sh start mynetwork wep 12345678 |
|
03-28-2008, 01:33 PM | #9 |
Evangelist
Posts: 423
Karma: 2153430
Join Date: Dec 2007
Device: BeBook
|
Hmm, still no joy.
|
03-28-2008, 03:22 PM | #10 |
Connoisseur
Posts: 53
Karma: 140
Join Date: Mar 2008
Device: iRex iLiad (v1) / Sony Librie
|
Does it work if you try it wired? This would give us an idea if it's a problem with the script or the wifi connection (via the script)
Last edited by cen; 03-28-2008 at 03:25 PM. |
03-28-2008, 05:42 PM | #11 |
Connoisseur
Posts: 53
Karma: 140
Join Date: Mar 2008
Device: iRex iLiad (v1) / Sony Librie
|
Problem solved, assuming you had the same issue as me. The script fails if /media/cf/newspapers/Guardian24/ doesn't exist (and I never bothered to create it as I put the script elsewhere )
Updated code to create the root newspaper dir if it doesnt exist (mkdir -p) To get the wifi working: uncomment the following lines #/usr/bin/wireless.sh start <SSID> <ENC_TYPE> <PASS> #/usr/bin/wireless.sh stop and replace <...> with your wifi details. Code:
#!/bin/sh export GUARDIAN_PATH=/media/cf/newspapers/Guardian24/ /usr/bin/wired.sh start #/usr/bin/wireless.sh start <SSID> <ENC_TYPE> <PASS> rm -rf $GUARDIAN_PATH/Guardian.pdf mkdir -p $GUARDIAN_PATH/Guardian.pdf echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><package><metadata><dc-metadata><Title>The Guardian 24h edition</Title><Description>Downloaded: `echo \`date\``</Description></dc-metadata><y-metadata><startpage>Guardian.pdf</startpage><image>icon.png</image><version>000</version></y-metadata></metadata></package>" > $GUARDIAN_PATH/Guardian.pdf/manifest.xml wget -O $GUARDIAN_PATH/Guardian.pdf/Guardian.pdf http://download.guardian.co.uk/g24/World.pdf cp $GUARDIAN_PATH/get-guardian/icon.png $GUARDIAN_PATH/Guardian.pdf/icon.png /usr/bin/wired.sh stop #/usr/bin/wireless.sh stop edit: sort of works, gets to 28% download of the PDF then stalls and craps out (but the PDF is created). YMMV Last edited by cen; 03-28-2008 at 05:54 PM. |
03-29-2008, 11:01 AM | #12 |
Evangelist
Posts: 423
Karma: 2153430
Join Date: Dec 2007
Device: BeBook
|
Still not having any luck. I can't test it wired, because I don't have a network cable. (I mean, what's the point of having a wifi network, then buying wires? ) Has anyone else got this to work with wifi?
|
03-29-2008, 12:38 PM | #13 |
Connoisseur
Posts: 53
Karma: 140
Join Date: Mar 2008
Device: iRex iLiad (v1) / Sony Librie
|
Not sure how familiar you are with the command line but if you were to fire up a shell on the iLiad and cd into the get-guardian directory and issue the command sh -x run.sh This should give you a better idea of where it is going wrong.
|
03-29-2008, 01:14 PM | #14 |
Evangelist
Posts: 423
Karma: 2153430
Join Date: Dec 2007
Device: BeBook
|
Well, I'm familiar enough with the shell to do that, but not familiar enough to understand the results! Here's the output:
Code:
+ export GUARDIAN_PATH=/media/cf/newspapers/Guardian24/ + GUARDIAN_PATH=/media/cf/newspapers/Guardian24/ + /usr/bin/wired.sh start run.sh: line 3: /usr/bin/wired.sh: No such file or directory + /usr/bin/wireless.sh start run.sh: line 4: /usr/bin/wireless.sh: No such file or directory + rm -rf /media/cf/newspapers/Guardian24//Guardian.pdf + mkdir /media/cf/newspapers/Guardian24//Guardian.pdf +++ date ++ echo Sat Mar 29 16:03:30 GMT 2008 + echo '<?xml version="1.0" encoding="utf-8"?><package><metadata><dc-metadata><Title>The Guardian 24h edition</Title><Description>Downloaded: Sat Mar 29 16:03:30 GMT 2008</Description></dc-metadata><y-metadata><startpage>Guardian.pdf</startpage><image>icon.png</image><version>000</version></y-metadata></metadata></package>' + wget -O /media/cf/newspapers/Guardian24//Guardian.pdf/Guardian.pdf http://download.guardian.co.uk/g24/World.pdf --16:03:30-- http://download.guardian.co.uk/g24/World.pdf => `/media/cf/newspapers/Guardian24//Guardian.pdf/Guardian.pdf' Resolving download.guardian.co.uk... 77.91.249.32 Connecting to download.guardian.co.uk|77.91.249.32|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 255,185 (249K) [application/pdf] 100%[====================================>] 255,185 288.43K/s 16:03:31 (287.81 KB/s) - `/media/cf/newspapers/Guardian24//Guardian.pdf/Guardian.pdf' saved [255185/255185] + cp /media/cf/newspapers/Guardian24//get-guardian/icon.png /media/cf/newspapers/Guardian24//Guardian.pdf/icon.png cp: cannot stat `/media/cf/newspapers/Guardian24//get-guardian/icon.png': No such file or directory + /usr/bin/wired.sh stop run.sh: line 10: /usr/bin/wired.sh: No such file or directory + /usr/bin/wireless.sh stop run.sh: line 11: /usr/bin/wireless.sh: No such file or directory |
03-29-2008, 01:39 PM | #15 |
Addict
Posts: 281
Karma: 904
Join Date: Oct 2007
Location: Kent, UK
Device: iRex iLiad, Psion 5MX, nokia n800
|
Just looking at this quickly:
i) Are you sure the manifest file is being created? You do not seem to be directing the output of the echo command to a file. I would have expected to see something like this at the end of the echo command Code:
> manifest.xml Can you look at the CF in a PC? Is it possible that the PDF has been downloaded okay and it in the subdirectory, but because there is no manifest file it won't open? |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The Guardian, modified | ajnorman | Recipes | 20 | 01-10-2014 12:02 PM |
Automatic News Download | brewjono | Calibre | 3 | 10-09-2010 09:49 AM |
Automatic Index of Books Available for Download | HarryT | BBeB/LRF Books | 6 | 09-11-2009 10:49 PM |
The Guardian Reviews the DX | poohbear_nc | News | 3 | 07-06-2009 10:33 AM |
Automatic Daily Comic Strip Download | Adam B. | iRex | 10 | 08-11-2007 06:33 AM |