def copyItemFields(): q1 = MediaItem(_CFG, _CFG['accountId']) q1.Query(_CFG['query']) item = q1.Next() while item: print "[{0}]: id: {1} refid: {2} long: {3}".format( q1.returnedCount, item['id'], item['reference_id'], item['long_description']) item = q1.Next() customFields = item.get('custom_fields', {}) customFields['website'] = 'CollegeHumor' date = dateutil.parser.parse( customFields.get('original_publish_date', "")) updateData = {} schedule = {} schedule['starts_at'] = date.isoformat() updateData['schedule'] = schedule updateData['custom_fields'] = customFields q1.Update(item['id'], updateData) print "{0}: Updated.".format(item['id']) item = q1.Next()
def testme(): # text = 'Thu, 16 Dec 2010 12:14:05 +0000' # date = (dateutil.parser.parse(text)) # print(date.isoformat()) # # 2010-12-16T12:14:05+00:00 # sys.exit() q1 = MediaItem(_CFG, _CFG['accountId']) q1.Query(_CFG['query']) log("Query returned [{0}] items.".format(q1.QueryCount())) item = q1.Next() while item: print "item: [{0}]: id: {1} refid: {2}".format(q1.returnedCount,item['id'], item['reference_id']) # r = q1.Delete(item['id']) # if r: # log("Delete failed: [{0}]".format(r)) item = q1.Next()
def deleteMediaItems(): q1 = MediaItem(_CFG, _CFG['accountId']) q1.Query(_CFG['query']) log("Query returned [{0}] items.".format(q1.QueryCount())) item = q1.Next() while item: print "Deleting: [{0}]: id: {1} refid: {2}".format(q1.returnedCount,item['id'], item['reference_id']) r = q1.Delete(item['id']) if r: log("Delete failed: [{0}]".format(r)) item = q1.Next()
def copyItemFields(): q1 = MediaItem(_CFG, _CFG['accountId']) q1.Query(_CFG['query']) item = q1.Next() while item: print "[{0}]: id: {1} refid: {2} long: {3}".format(q1.returnedCount,item['id'], item['reference_id'],item['long_description']) if item: data = {} data['long_description'] = item.get('reference_id',"") if not item.get('long_description', None): q1.Update( item['id'], data) print "Updated." item = q1.Next()