import os, re, requests
rootdir = '_posts'

for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        filename = os.path.join(subdir, file)

    	f = open(filename, "r")
    	contents = f.readlines()
    	f.close()

    	# Find first image
    	for key, line in enumerate(contents):
    		src = re.search('\!\[.*?\]\((.*?)\)', line)
    		if src:
    			wordpress_src = re.search('/blog/images/wordpress/(.*)', src.group(1))
    			if wordpress_src:
	    			image_src = wordpress_src.group(1)
	    			path = 'images/wordpress/'+image_src
	    			print 'Retrieving ' + path + '...'
	    			if not os.path.isfile(path):
	    				print path
		    			f = open(path, "w")
		    			f.write(requests.get("http://blog.stackoverflow.com/wp-content/uploads/" + wordpress_src.group(1)).content)
		    			f.close()

    	continue
    	f = open(filename, "w")
    	contents = "".join(contents)
    	f.write(contents)
    	f.close()
@@ -259,591 +259,234 @@
     
-%09for key, line in enumerate(contents):%0A    %09%09src = re.search('%5C!%5C%5B.*?%5C%5D%5C((.*?)%5C)', lin
+    if re.search('podcast', filenam
 e)
+:
 %0A    
-%09%09if src:%0A    %09%09%09wordpress_src = re.search('/blog/images/wordpress/(.*)', src.group(1))%0A    %09%09%09if wordpress_src
+        if re.search('%5Ehero: ', contents%5B6%5D)
 :%0A
-%09
     
-%09%09%09image_src = wordpress_src.group(1)%0A%09    %09%09%09path = 'images/wordpress/'+image_src%0A%09
+        
     
-%09%09%09
 print 
-'Retrieving ' + path + '...'%0A%09    %09%09%09if not os.path.isfile(path):%0A%09    %09%09%09%09print path%0A%09%09    %09%09%09f = open(path, %22w%22)%0A%09%09    %09%09%09f.write(requests.get(%22http://blog.stackoverflow.com/wp-content/uploads/%22 + wordpress_src.group(1)).content)%0A%09%09    %09%09%09f.close()%0A%0A    %09continue%0A
+filename%0A                contents.insert(6, 'hero: /blog/images/category/podcasts.jpg%5Cn')%0A            
     
-%09
 f = 
+file.
 open
@@ -509,51 +509,28 @@
     
-%09contents = %22%22.join(contents)%0A
+     
     
-%09
+   
 f.write(
 cont
@@ -525,16 +525,24 @@
 f.write(
+%22%22.join(
 contents
@@ -542,22 +542,34 @@
 ontents)
+)
 %0A    
-%09
+            
 f.close(
@@ -561,16 +561,17 @@
        f.close()
+%0A

Add default images for podcasts if necessary