def convert_to(self, from_model): result_dict = [] current_version = from_model.app.current_version reviewed_version = _get_reviewed_version(from_model.app) if current_version and from_model.app.review_status: app_infos = { 'pk': from_model.id, 'id': from_model.app.id, 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0, 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0, 'name': from_model.app.name, 'order': from_model.order, 'short_desc': from_model.short_desc, 'description': reviewed_version.description, 'version': current_version.version, 'version_code': current_version.version_code, 'package_name': from_model.app.package_name, 'price': float(current_version.price), 'rate': float(from_model.app.rate), 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'category_id': from_model.app.category.id, 'sub_category_id': from_model.app.sub_category.id, 'cate_name': from_model.app.category.name, 'sub_cate_name': from_model.app.sub_category.name, 'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True), 'download_count': from_model.app.downloads_count, 'size': friendly_size(current_version.size), 'min_sdk_version': current_version.min_sdk_version, } app_infos.update(_convert_app_labels(from_model.app.label)) result_dict.append(app_infos) return result_dict
def convert_to(self, from_model): result_dict = [] group_content = get_region_group(from_model) current_version = from_model.app.current_version if current_version and from_model.app.review_status: app_infos = { 'pk': from_model.id, 'id': from_model.app.id, 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0, 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0, 'name': from_model.app.name, 'tag': from_model.app.tag, 'version': current_version.version, 'version_code': current_version.version_code, 'package_name': from_model.app.package_name, 'price': float(current_version.price), 'rate': float(from_model.app.rate), 'icon_url': current_version.icon_url or \ parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'cate_name': from_model.app.category.name, 'sub_cate_name': from_model.app.sub_category.name, 'order': from_model.order, 'type': from_model.type, 'download_count': from_model.app.downloads_count, 'size': friendly_size(current_version.size), 'min_sdk_version': current_version.min_sdk_version, 'region':group_content, } app_infos.update(_convert_app_labels(from_model.app.label)) result_dict.append(app_infos) return result_dict
def convert_to(self, from_model): subject_item = { 'id': from_model.id, 'subject_id': from_model.subject.id, 'title': from_model.title, 'description': from_model.description, 'icon_url': from_model.icon_url or parse_url( from_model.icon_path.url if from_model.icon_path else ''), 'order': from_model.order, 'subject_info': { 'name': from_model.subject.name, 'sub_title': from_model.subject.sub_title, 'click_count': from_model.subject.clicks_count, 'description': from_model.subject.description, 'pub_date': datetime2timestamp(from_model.subject.pub_date, convert_to_utc=True), } } apps = [] for subject_app in from_model.apps.all().order_by('order'): current_version = subject_app.app.current_version reviewed_version = _get_reviewed_version(subject_app.app) if current_version: app_infos = { 'pk': subject_app.id, 'order': subject_app.order, 'id': subject_app.app.id, 'tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1) else 0, 'download_tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1 and (current_version.t_status == 6 or subject_app.app.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': subject_app.app.t_id if subject_app.app.t_id else 0, 'name': subject_app.app.name, 'description': reviewed_version.description, 'version': current_version.version, 'version_code': current_version.version_code, 'package_name': subject_app.app.package_name, 'price': float(subject_app.app.price), 'rate': float(subject_app.app.rate), 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True), 'download_count': subject_app.app.downloads_count, 'size': friendly_size(current_version.size), 'min_sdk_version': current_version.min_sdk_version, } app_infos.update(_convert_app_labels(subject_app.app.label)) apps.append(app_infos) subject_item['apps'] = apps return [subject_item]
def convert_to(self, from_model): result_dict = [] current_version = from_model.current_version reviewed_version = _get_reviewed_version(from_model) blocked_devices = from_model.blocked_devices if from_model.blocked_devices else '' unique_devices = set(dev.strip() for dev in blocked_devices.strip().split(',') if dev) external_download_url = current_version.external_download_url if current_version.external_download_url else '' external_download_url_set = set(link for link in external_download_url.strip().split(' ') if link) if current_version and from_model.review_status: result = { 'id': from_model.id, 'tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1) else 0, 'download_tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1 and (from_model.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': from_model.t_id if from_model.t_id else 0, 'charge_mode': from_model.t_chargemode, 'name': from_model.name, 'developer': _get_app_developer(current_version), 'description': reviewed_version.description, 'update_note': current_version.update_note or "", 'price': float(current_version.price), 'rate': float(from_model.rate), 'package_name': from_model.package_name, 'package_sig': from_model.package_sig, 'package_hash': current_version.package_hash, 'download_count': from_model.downloads_count, 'preview_icon_urls': reviewed_version.icon_urls(), 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'download_url': current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else ''), 'external_download_urls':list(external_download_url_set), 'version': current_version.version, 'version_code': current_version.version_code, 'size': friendly_size(current_version.size), 'category_id': from_model.category.id, 'sub_category_id': from_model.sub_category.id, 'cate_name': from_model.category.name, 'sub_cate_name': from_model.sub_category.name, 'update_date': datetime2timestamp(current_version.modified_time, convert_to_utc=True), 'rate_count': from_model.reviews_count, 'order': from_model.order, 'min_sdk_version': current_version.min_sdk_version, 'promote': -1, 'blocked_devices': list(unique_devices), } result.update(_convert_app_labels(from_model.label)) #tianyi blacklist app control #promote_result = get_promote_app(from_model) #result.update(promote_result) if not result['download_url']: result['download_url'] = _get_prev_version_download_url(from_model, current_version.id) result_dict.append(result) return result_dict
def convert_to(self, from_model): result_dict = [] group_content = get_region_group(from_model) model = { 'pk': from_model.id, 'app_list_id': from_model.app_list.id, 'order': from_model.order, 'title': from_model.title, 'description': from_model.description, 'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''), 'large_icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''), 'image_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''), 'attr': from_model.attr, 'type': from_model.type, 'extra_infos': {} if not from_model.extra_infos else simplejson.loads(from_model.extra_infos), 'region': group_content, } if from_model.app and from_model.app.current_version and from_model.app.review_status: current_version = from_model.app.current_version reviewed_version = _get_reviewed_version(from_model.app) app_infos = { 'id': from_model.app.id, 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0, 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0, 'name': from_model.app.name, 'developer': _get_app_developer(current_version), 'description': reviewed_version.description, 'preview_icon_urls': reviewed_version.icon_urls(), 'package_name': from_model.app.package_name, 'package_sig': from_model.app.package_sig, 'version': current_version.version, 'version_code': str(current_version.version_code), 'tag': from_model.app.tag, 'price': float(current_version.price), 'rate': float(from_model.app.rate), 'icon_url': current_version.icon_url or \ parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'category_id': from_model.app.category.id if from_model.app.category else 0, 'cate_name': from_model.app.category.name if from_model.app.category else '', 'sub_category_id': from_model.app.sub_category.id, 'sub_cate_name': from_model.app.sub_category.name, 'download_count': from_model.app.downloads_count, 'size': friendly_size(current_version.size), 'update_time': datetime2timestamp(current_version.modified_time, convert_to_utc=True), 'min_sdk_version': current_version.min_sdk_version, } app_infos.update(_convert_app_labels(from_model.app.label)) model.update({'app': app_infos}) result_dict.append(model) return result_dict
def convert_to(self, from_model): subject_item = { 'id': from_model.id, 'subject_id': from_model.subject.id, 'title': from_model.title, 'description': from_model.description, 'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''), 'order': from_model.order, 'subject_info': { 'name': from_model.subject.name, 'sub_title': from_model.subject.sub_title, 'click_count': from_model.subject.clicks_count, 'description': from_model.subject.description, 'pub_date': datetime2timestamp(from_model.subject.pub_date, convert_to_utc=True), } } apps = [] for subject_app in from_model.apps.all().order_by('order'): current_version = subject_app.app.current_version reviewed_version = _get_reviewed_version(subject_app.app) if current_version: app_infos = { 'pk': subject_app.id, 'order': subject_app.order, 'id': subject_app.app.id, 'tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1) else 0, 'download_tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1 and (current_version.t_status == 6 or subject_app.app.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': subject_app.app.t_id if subject_app.app.t_id else 0, 'name': subject_app.app.name, 'description': reviewed_version.description, 'version': current_version.version, 'version_code': current_version.version_code, 'package_name': subject_app.app.package_name, 'price': float(subject_app.app.price), 'rate': float(subject_app.app.rate), 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True), 'download_count': subject_app.app.downloads_count, 'size': friendly_size(current_version.size), 'min_sdk_version': current_version.min_sdk_version, } app_infos.update(_convert_app_labels(subject_app.app.label)) apps.append(app_infos) subject_item['apps'] = apps return [subject_item]
def process_incremental_update(self, results, app_infos): package_hash_dict = dict([(app[UA_PACKAGE_NAME], app[UA_PACKAGE_HASH]) for app in app_infos if len(app) > UA_PACKAGE_HASH]) for result in results: result['patch_size'] = 0 old_hash = package_hash_dict.get(result['package_name'], None) if not old_hash: continue old_hash = old_hash.lower() new_hash = result.get('package_hash', None) if not new_hash: continue patch_info = self.patch_db.get_patch_info(old_hash, new_hash) if not patch_info: # On demand calculate patch # self.patch_db.add_job(old_hash, new_hash) continue result['patch_size'] = friendly_size(patch_info['patch_size']) del result['package_hash']
def app_updates(request): ''' clientid: client's unique id, client refers to the device where apps to be installed on source: where the app update request is sent from, usually consists of "<package_name>+<version_code>" deviceinfo: a piece of info which usually consists of "<model_name>+<os_version>" ''' client_id = get_parameter_POST(request, 'clientid') chn = get_parameter_GET( request, 'chn', required=False, default=None) or get_parameter_POST( request, 'chn') source = get_parameter_POST(request, 'source') app_infos = get_parameter_POST( request, 'appinfos', convert_func=simplejson.loads) os = get_parameter_POST( request, 'os', required=False, convert_func=int, default=None) device_info = get_parameter_POST(request, 'deviceinfo', required=False) screen_size = get_parameter_POST(request, 'screensize', required=False) platform = get_parameter_POST( request, 'platform', convert_func=to_int_array, default='1') jailbreak = get_parameter_POST( request, 'jailbreak', convert_func=int, default=0) ip = get_parameter_META( request, 'REMOTE_ADDR', required=False, default=u'') for q in (chn, client_id, source, device_info, app_infos, ip): if isinstance(q, HttpResponse): return q if jailbreak == -1: # this is used for pc client, for which, there's no jailbreak concept, # and it requires the app to keep the jailbreak status jailbreak = None elif jailbreak == 1: jailbreak = True else: jailbreak = False if len(platform) == 1: platform = platform[0] log_data = '|'.join([str(app_info['packageName']) + ':' + str(app_info['packageVersion']) for app_info in app_infos]) app_upload_logger.info('chn=%s, ip=%s, clientid=%s, source=%s, deviceinfo=%s, appinfos=%s, os=%s, screensize=%s, platform=%s, jailbreak=%s' % (chn, ip, client_id, source, device_info, log_data, str(os), screen_size, str(platform), str(jailbreak))) for app in app_infos: app['packageVersion'] = int(app['packageVersion']) if chn != 'ofw': app_infos = [app for app in app_infos if app['packageName'] != 'com.diandian.appstore'] if len(app_infos) > 0: user_app_data = { 'apps': app_infos, 'device_info': device_info, 'os': os, 'screen_size': screen_size, 'platform': platform, 'jailbreak': jailbreak, 'source': source } user_db.update_apps_installed(client_id, user_app_data) else: # client may update an empty list to just query the user app updates user_app_data = user_db.query_apps_installed(client_id) if user_app_data is not None and 'apps' in user_app_data: app_infos = user_app_data['apps'] if app_infos is not None and len(app_infos) > 0: if jailbreak is not None: results = app_db.query_updates( app_infos, platform=platform, jailbreak=jailbreak) else: results = app_db.query_updates( [app for app in app_infos if app['appType'] == 0], platform=platform, jailbreak=jailbreak) results += app_db.query_updates( [app for app in app_infos if app['appType'] != 0], platform=platform, jailbreak=jailbreak) else: results = [] # support incremental updates for r in results: r['patch_size'] = 0 # 0 by default app = [a for a in app_infos if a['packageName'] == r['package_name']] if app: app = app[0] old_hash, new_hash = app.get( 'packageHash', None), r.get('package_hash', None) if old_hash and new_hash: old_hash = old_hash.lower() patch_info = patch_db.get_patch_info(old_hash, new_hash) if patch_info: r['patch_size'] = friendly_size(patch_info['patch_size']) # else: # On demand calculate patch #patch_db.add_job(old_hash, new_hash) del r['package_hash'] else: continue # only return chars max size 400 for update_note to save traffic. for r in results: if 'update_note' in r: r['update_note'] = r['update_note'][:400] results = app_post_process( results, os=os, screen_size=screen_size, chn=chn) logger.info( 'app_updates, chn=%s, clientid=%s, results=%d' % (chn, client_id, len(results))) return results
def app_updates(request): ''' clientid: client's unique id, client refers to the device where apps to be installed on source: where the app update request is sent from, usually consists of "<package_name>+<version_code>" deviceinfo: a piece of info which usually consists of "<model_name>+<os_version>" ''' compact = get_parameter_GET( request, 'compact', convert_func=int, required=False, default=None) if compact is not None: client_id = get_parameter_GET(request, 'clientid') source = get_parameter_GET(request, 'source') app_infos = [] if compact == 1: for arg in request.raw_post_data.split('&'): kv = arg.split('=', 1) if len(kv) != 2: continue if kv[0] == 'ks[]': fields = kv[1].split('|') if len(fields) != 2: continue app_infos.append({ "packageName": fields[0], "packageVersion": long(fields[1]), "packageSig": "", "appName": "", }) elif kv[0] == 'os': os = int(kv[1]) elif compact == 2: http_head = get_parameter_META( request, 'HTTP_HEAD', convert_func=simplejson.loads, required=False, default=u'') os = http_head['sdk'] p = get_parameter_POST(request, 'p') p = simplejson.loads(p) if p else None if p: for k, v in p.iteritems(): app_infos.append({ "packageName": k, "packageVersion": 0, "packageSig": "", "appName": v, }) else: client_id = get_parameter_POST(request, 'clientid') source = get_parameter_POST(request, 'source') app_infos = get_parameter_POST( request, 'appinfos', convert_func=simplejson.loads) os = get_parameter_POST( request, 'os', required=False, convert_func=int, default=None) device_info = get_parameter_POST(request, 'deviceinfo', required=False) screen_size = get_parameter_POST(request, 'screensize', required=False) platform = get_parameter_POST( request, 'platform', convert_func=to_int_array, default='1') jailbreak = get_parameter_POST( request, 'jailbreak', convert_func=int, default=0) save_to_db = get_parameter_GET( request, 'savetodb', convert_func=int, default=1) == 1 ip = get_parameter_META( request, 'REMOTE_ADDR', required=False, default=u'') with_details = get_parameter_GET( request, 'details', convert_func=bool, required=False) for q in (client_id, source, device_info, app_infos, ip): if isinstance(q, HttpResponse): logger.info( 'app_updates, ip=%s, clientid=%s, invalid request' % (ip, client_id)) return q if jailbreak == -1: # this is used for pc client, for which, there's no jailbreak concept, # and it requires the app to keep the jailbreak status jailbreak = None elif jailbreak == 1: jailbreak = True else: jailbreak = False if len(platform) == 1: platform = platform[0] log_data = '|'.join([str(app_info['packageName']) + ':' + str(app_info['packageVersion']) for app_info in app_infos]) app_upload_logger.info('ip=%s, clientid=%s, source=%s, deviceinfo=%s, appinfos=%s, os=%s, screensize=%s, platform=%s, jailbreak=%s, savetodb=%s, compact=%s' % (ip, client_id, source, device_info, log_data, str(os), screen_size, str(platform), str(jailbreak), str(save_to_db), str(compact))) for app in app_infos: app['packageVersion'] = int(app['packageVersion']) if len(app_infos) > 0: user_app_data = { 'apps': app_infos, 'device_info': device_info, 'os': os, 'screen_size': screen_size, 'platform': platform, 'jailbreak': jailbreak, 'source': source } if save_to_db: user_db.update_apps_installed(client_id, user_app_data) else: # client may update an empty list to just query the user app updates user_app_data = user_db.query_apps_installed(client_id) if user_app_data is not None and 'apps' in user_app_data: app_infos = user_app_data['apps'] if app_infos is not None and len(app_infos) > 0: if jailbreak is not None: results = app_db.query_updates( app_infos, platform=platform, jailbreak=jailbreak) else: results = app_db.query_updates( [app for app in app_infos if app['appType'] == 0], platform=platform, jailbreak=jailbreak) results += app_db.query_updates( [app for app in app_infos if app['appType'] != 0], platform=platform, jailbreak=jailbreak) else: results = [] # support incremental updates for r in results: r['patch_size'] = 0 # 0 by default app = [a for a in app_infos if a['packageName'] == r['package_name']] if app: app = app[0] old_hash, new_hash = app.get( 'packageHash', None), r.get('package_hash', None) if old_hash and new_hash: old_hash = old_hash.lower() patch_info = patch_db.get_patch_info(old_hash, new_hash) if patch_info: r['patch_size'] = friendly_size(patch_info['patch_size']) # else: # On demand calculate patch #patch_db.add_job(old_hash, new_hash) del r['package_hash'] else: continue results = app_post_process( results, with_details=with_details, os=os, screen_size=screen_size) logger.info( 'app_updates, clientid=%s, results=%d' % (client_id, len(results))) return results
def convert_to(self, from_model): result_dict = [] group_content = get_region_group(from_model) model = { 'pk': from_model.id, 'app_list_id': from_model.app_list.id, 'order': from_model.order, 'title': from_model.title, 'description': from_model.description, 'icon_url': from_model.icon_url or parse_url( from_model.icon_path.url if from_model.icon_path else ''), 'large_icon_url': from_model.icon_url or parse_url( from_model.icon_path.url if from_model.icon_path else ''), 'image_url': from_model.icon_url or parse_url( from_model.icon_path.url if from_model.icon_path else ''), 'attr': from_model.attr, 'type': from_model.type, 'extra_infos': {} if not from_model.extra_infos else simplejson.loads(from_model.extra_infos), 'region': group_content, } if from_model.app and from_model.app.current_version and from_model.app.review_status: current_version = from_model.app.current_version reviewed_version = _get_reviewed_version(from_model.app) app_infos = { 'id': from_model.app.id, 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0, 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0, 'name': from_model.app.name, 'developer': _get_app_developer(current_version), 'description': reviewed_version.description, 'preview_icon_urls': reviewed_version.icon_urls(), 'package_name': from_model.app.package_name, 'package_sig': from_model.app.package_sig, 'version': current_version.version, 'version_code': str(current_version.version_code), 'tag': from_model.app.tag, 'price': float(current_version.price), 'rate': float(from_model.app.rate), 'icon_url': current_version.icon_url or \ parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'category_id': from_model.app.category.id if from_model.app.category else 0, 'cate_name': from_model.app.category.name if from_model.app.category else '', 'sub_category_id': from_model.app.sub_category.id, 'sub_cate_name': from_model.app.sub_category.name, 'download_count': from_model.app.downloads_count, 'size': friendly_size(current_version.size), 'update_time': datetime2timestamp(current_version.modified_time, convert_to_utc=True), 'min_sdk_version': current_version.min_sdk_version, } app_infos.update(_convert_app_labels(from_model.app.label)) model.update({'app': app_infos}) result_dict.append(model) return result_dict
def convert_to(self, from_model): result_dict = [] current_version = from_model.current_version reviewed_version = _get_reviewed_version(from_model) blocked_devices = from_model.blocked_devices if from_model.blocked_devices else '' unique_devices = set(dev.strip() for dev in blocked_devices.strip().split(',') if dev) external_download_url = current_version.external_download_url if current_version.external_download_url else '' external_download_url_set = set( link for link in external_download_url.strip().split(' ') if link) if current_version and from_model.review_status: result = { 'id': from_model.id, 'tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1) else 0, 'download_tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1 and (from_model.t_chargemode not in (0, 4) or not (current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0, 'backup_tid': from_model.t_id if from_model.t_id else 0, 'charge_mode': from_model.t_chargemode, 'name': from_model.name, 'developer': _get_app_developer(current_version), 'description': reviewed_version.description, 'update_note': current_version.update_note or "", 'price': float(current_version.price), 'rate': float(from_model.rate), 'package_name': from_model.package_name, 'package_sig': from_model.package_sig, 'package_hash': current_version.package_hash, 'download_count': from_model.downloads_count, 'preview_icon_urls': reviewed_version.icon_urls(), 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''), 'download_url': current_version.download_url or \ parse_url(current_version.download_path.url if current_version.download_path else ''), 'external_download_urls':list(external_download_url_set), 'version': current_version.version, 'version_code': current_version.version_code, 'size': friendly_size(current_version.size), 'category_id': from_model.category.id, 'sub_category_id': from_model.sub_category.id, 'cate_name': from_model.category.name, 'sub_cate_name': from_model.sub_category.name, 'update_date': datetime2timestamp(current_version.modified_time, convert_to_utc=True), 'rate_count': from_model.reviews_count, 'order': from_model.order, 'min_sdk_version': current_version.min_sdk_version, 'promote': -1, 'blocked_devices': list(unique_devices), } result.update(_convert_app_labels(from_model.label)) #tianyi blacklist app control #promote_result = get_promote_app(from_model) #result.update(promote_result) if not result['download_url']: result['download_url'] = _get_prev_version_download_url( from_model, current_version.id) result_dict.append(result) return result_dict