Tuesday, April 14, 2015

Script for downloading all Popular Electronics magazines

The great page http://www.americanradiohistory.com/ has got loads and loads of old radio and electronics magaizines for download. Among these are the venerable Popular Electronics magazine which was published between October 1954 and October 1982. These old magazines are really great, not only for historic reasons and for fun, but there are also lots of electronic circuits, loadspeaker designs, and more in there that you can still build directly from the articles or you can use them as inspiration for new projects.


The most famous issue is probably the January 1975 issue presenting the Altair 8800 computer kit. Now you can build your own based on the original instructions :-)

I have made a simple Python script that downloads all the 337 isssues of the Popular Electronic magazine. The script is based on a script from Peter B. Mark that downloads all 73 ham radio magazines from arxive.org (btw, a highly recommended magazine).

Using the script, I can read through all the editions on my iPad even when I am offline, for example when I am waiting for my flight on an airport with nothing else to do and no WiFi.

Disclaimer: The whole bunch of magazines will occupy about 3.5GB of disk space. Furthermore, the naming of the directories on americanradiohistory is not concise, so the script might seem a bit crappy. But it works! Feature: If you exit the script while it runs, it will not download previously downloaded magazines when you restart. Good luck.

#!/usr/bin/python
"""
Download pdfs of Popular Electronics Magazine

"""
import os
import urllib2
import urllib

START_YEAR = 1954
END_YEAR = 1982
OUTPUT_DIR = "PopularElectronics"

MISSING = ('PopularElectronics/Pop-1954-01.pdf', 'PopularElectronics/Pop-1954-02.pdf', 'PopularElectronics/Pop-1954-03.pdf', 'PopularElectronics/Pop-1954-04.pdf', 'PopularElectronics/Pop-1954-05.pdf', 'PopularElectronics/Pop-1954-06.pdf', 'PopularElectronics/Pop-1954-07.pdf', 'PopularElectronics/Pop-1954-08.pdf', 'PopularElectronics/Pop-1954-09.pdf')


def main():
    if not os.path.exists(OUTPUT_DIR):
        os.mkdir(OUTPUT_DIR)
    downloadPopMag("Pop")
    downloadPopMag("Poptronics")

def downloadPopMag(prefix):
    for year in range(START_YEAR, END_YEAR + 1):
        for month in range(1,13):
            fileName = "%s/Pop-%d-%02d.pdf" % (OUTPUT_DIR, year, month)
            if not os.path.exists(fileName) and fileName not in MISSING:
urlyear = year - 1900
tenyear = urlyear - (urlyear % 10)
strtenyear = str(tenyear) + "s"                
if(urlyear > 69):
urlyear = year

editionString = "%s-%d-%02d" % (prefix, year, month)

url = "http://www.americanradiohistory.com/Archive-Poptronics/%s/%d/%s.pdf" % (strtenyear, urlyear, editionString)
                print("Downloading: %s..." % url)
                print("To: %s" % fileName)
                try: pdfData = urllib2.urlopen(url).read()
except urllib2.HTTPError as e:
# Probably wrong prefix. Try with the other prefix later
print e.code
else:
                outFile = open(fileName, "wb")
                outFile.write(pdfData)
                outFile.close()
            else:
                print("Skipping: %s" % fileName)


if __name__ == "__main__":
    main()





1 comment:

  1. File "PopE.py", line 28
    urlyear = year - 1900
    ^
    IndentationError: unindent does not match any outer indentation level

    ReplyDelete