Created
          August 31, 2016 16:46 
        
      - 
      
 - 
        
Save anonymous/2c2bf6895d8976b57e5293a461eeaee4 to your computer and use it in GitHub Desktop.  
     Download 'The Economist Audio Editions' For Free
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import hashlib | |
| import urllib | |
| import re | |
| import os | |
| issueid = 20151205 # Format: YYYYMMDD (only Saturdays) | |
| downloadFolder = '/public/%d' % issueid | |
| secret = hashlib.md5() | |
| secret.update('23c341d479b2fd056c497c80f4223ca5%d' % issueid) | |
| manifestURL = 'http://media.economist.com/sites/default/files/digitaleditions/%s/Android/PHONE_MANIFEST_EU.gzz' | |
| manifest = urllib.urlopen(manifestURL % issueid).read() | |
| archives = re.findall('http:\/\/media.economist.com\/sites\/default\/files\/digitaleditions\/\d{8}\/Audio\/(.*?).cdo', manifest) | |
| os.system('mkdir %s' % downloadFolder) | |
| for a in archives: | |
| aURL = 'http://media.economist.com/sites/default/files/digitaleditions/%d/Audio/%s.cdo' % (issueid, a) | |
| path = '%s/%s.zip' % (downloadFolder, a) | |
| unzip = 'unzip -P %s %s -d %s && rm -rf %s' % (secret.hexdigest(), path, downloadFolder, path) # for UNIX & Linux | |
| urllib.urlretrieve(aURL, path) | |
| os.system(unzip) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment