(cls, app, type, src)
从src公众号迁移某种类型的永久素材到app公众号
从src公众号迁移某种类型的永久素材到app公众号
从src公众号迁移某种类型的永久素材到app公众号
def migrate_type(cls, app, type, src):
        """从src公众号迁移某种类型的永久素材到app公众号"""
        materials = src.get_materials(type)
        if type == Material.Type.NEWS:
            return app.migrate_articles(app, src)
        else:
            migrated = []
            for material in materials:
                # TODO: 视频好像是down_url
                url = material.get("url") or material.get("down_url")
                resp = requests.get(url)

                # 上传素材
                record = app.upload_material(resp, permenant=True, save=True)
                migrated.append(record)
            return migrated
def migrate_type ( cls , app , type , src ) : materials = src . get_materials ( type ) if type == Material . Type . NEWS : return app . migrate_articles ( app , src ) else : migrated = [ ] for material in materials : # TODO: 视频好像是down_url url = material . get ( "url" ) or material . get ( "down_url" ) resp = requests . get ( url ) # 上传素材 record = app . upload_material ( resp , permenant = True , save = True ) migrated . append ( record ) return migrated