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 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()