Author: anil
Date: 2008-05-04 23:54:29 -0400 (Sun, 04 May 2008)
New Revision: 16530

Added:
   StreetsblogSetup/trunk/print_sfilms_attachments.py
   StreetsblogSetup/trunk/resize_wordpress.py
Log:
Added two utilites that are used in migrating/recovering streetfilms

Added: StreetsblogSetup/trunk/print_sfilms_attachments.py
===================================================================
--- StreetsblogSetup/trunk/print_sfilms_attachments.py                          
(rev 0)
+++ StreetsblogSetup/trunk/print_sfilms_attachments.py  2008-05-05 03:54:29 UTC 
(rev 16530)
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+#uploads URL
+
+import MySQLdb
+db = MySQLdb.connect(db='sfilms_live', user='root', passwd='root')
+c = db.cursor()
+query = 'select post_title, ID from wp_posts where post_type="post"'
+c.execute(query)
+results = c.fetchall()
+for title, ID in results:
+    #print title
+    query = "SELECT guid, post_title FROM wp_posts WHERE post_parent = %s AND 
post_type = 'attachment'" % ID
+    c.execute(query)
+    attachments = c.fetchall()
+    videos = []
+    images = []
+    for guid, title in attachments:
+        guid_pieces = guid.split('.')
+        filetype = guid_pieces.pop()
+        if filetype == "flv":
+            videos.append(guid)
+            #print "\t" + guid + "\t" + filetype
+        if filetype == "jpg":
+            images.append(guid)  
+            #print "\t" + guid + "\t" + filetype
+
+        print guid.replace("http://www.streetfilms.org/";, "")


Property changes on: StreetsblogSetup/trunk/print_sfilms_attachments.py
___________________________________________________________________
Name: svn:executable
   + *

Added: StreetsblogSetup/trunk/resize_wordpress.py
===================================================================
--- StreetsblogSetup/trunk/resize_wordpress.py                          (rev 0)
+++ StreetsblogSetup/trunk/resize_wordpress.py  2008-05-05 03:54:29 UTC (rev 
16530)
@@ -0,0 +1,29 @@
+#!/usr/bin/env python 
+import Image
+import os
+
+path = "/Users/anil/Sites/sfilms/trunk/wp-content/uploads"
+years = os.listdir(path)
+
+#year loop
+for year in years:
+    print year
+    months = os.listdir(path+"/"+year)
+    #month loop
+    for month in months:
+        print month
+        uploads = os.listdir(path+"/"+year+"/"+month)
+        #all uploads within a month
+        for upload in uploads:
+            if upload.find('.thumbnail.') == -1:
+                extension = upload.split(".").pop()
+                if extension == "jpg" or extension == "png":
+                    posterFileName = upload
+                    posterFile = Image.open(path+"/"+year+"/"+month+"/"+upload)
+                    width = 128
+                    height = 85
+
+                    thumbFile = posterFile.resize((width, height), 
Image.ANTIALIAS) 
+
+                    filename, ext = posterFileName.split(".")
+                    
thumbFile.save(path+"/"+year+"/"+month+"/"+filename+".thumbnail." + ext)


Property changes on: StreetsblogSetup/trunk/resize_wordpress.py
___________________________________________________________________
Name: svn:executable
   + *



--
Archive: 
http://www.openplans.org/projects/opencore/lists/openplans-svn/archive/2008/05/1209959681305
To unsubscribe send an email with subject unsubscribe to [EMAIL PROTECTED]  
Please contact [EMAIL PROTECTED] for questions.

Reply via email to