示例#1
0
def get_report():
    """
    """
    http = httplib2.Http()
    url = "http://mapi.affle.co/publisher.php?cId=all&key=63389e65c6fe8cd5f7b2f8d12e698907"
    headers = {"Content-Type": "application/json"}
    response, content = http.request(url, 'GET', headers=headers)
    offers = yajl.loads(content)['data']
    offers_list_new = []  ##
    offers_list_old = OfferList.find_one(dict(
        _id=61)).offer_list if OfferList.find_one(dict(_id=61)) else []  ##
    for offer in offers:
        o = Offers(parse_offer(offer))
        re = Offers.find_one(
            dict(title=o.title,
                 geo_targeting=o.geo_targeting,
                 click_url=o.click_url))
        if re:
            offers_list_new.append(re._id)  ##
            re.advertiser_id = re.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.title = o.title
            re.platform = o.platform
            # re.package_name = o.package_name
            # re.mini_version = o.mini_version
            re.click_url = o.click_url
            re.banner_url = o.banner_url
            re.preview_url = o.preview_url
            re.total_cap = o.total_cap
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.cap = o.cap
            re.payment = o.payment
            re.geo_targeting = o.geo_targeting
            re.create_time = o.create_time
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.is_expired = False  ##
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False  ##
            offers_list_new.append(o._id)  ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=61))  ##
    if offers_list:  ##
        offers_list._id = 61  ##
        offers_list.offer_list = offers_list_new  ##
        offers_list.save()  ##
    else:  ##
        offers_list = OfferList(  ##
            dict(  ##
                _id=61,  ##
                offer_list=offers_list_new  ##
            )  ##
        )  ##
        offers_list.save()  ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new))  ##
    for offer_id in is_expired_offers:  ##
        offer = Offers.find_one(dict(_id=offer_id))  ##
        try:
            offer.is_expired = True  ##
            offer.save()
        except AttributeError:
            continue
示例#2
0
def get_report():
    """
    """
    http = httplib2.Http()
    url_ios = "http://api.acekoala.com/api/offers?app_key=4603af3476d9b60bfc5d5cdaa577bdca&platform=Ios"
    url_android = "http://api.acekoala.com/api/offers?app_key=4603af3476d9b60bfc5d5cdaa577bdca&platform=Android"
    # url_ios = "http://api.acekoala.com/api/offers?app_key=8dedbea4d48580075b14cd083e5c5f8e&platform=Android"
    # url_android = "http://api.acekoala.com/api/offers?app_key=8dedbea4d48580075b14cd083e5c5f8e&platform=Android&country=us,ru"
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json"
    }
    response_ios, content_ios = http.request(url_ios, 'GET', headers=headers)
    response_android,content_android = http.request(url_android, 'GET', headers=headers)
    offers_ios = yajl.loads(content_ios)['data']
    offers_android = yajl.loads(content_android)['data']
    offers = offers_ios + offers_android
    offers_list_new = [] ##
    offers_list_old = OfferList.find_one(dict(_id=137)).offer_list if OfferList.find_one(dict(_id=137)) else [] ##
    for offer in offers:
        o = Offers(parse_offer(offer))
        re = Offers.find_one(dict(title=o.title, geo_targeting=o.geo_targeting, click_url=o.click_url))
        if re:
            offers_list_new.append(re._id) ##
            re.is_expired = False ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.package_name = o.package_name
            re.title = o.title
            re.preview_url = o.preview_url
            re.desciption = o.desciption
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.total_cap = o.total_cap
            re.cap = o.cap
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.mini_version = o.mini_version
            re.payment = o.payment
            re.platform = o.platform
            re.geo_targeting = o.geo_targeting
            re.banner_url = o.banner_url
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False ##
            offers_list_new.append(o._id) ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=137)) ##
    if offers_list: ##
        offers_list._id = 137 ##
        offers_list.offer_list = offers_list_new ##
        offers_list.save() ##
    else: ##
        offers_list = OfferList( ##
            dict( ##
                _id=137, ##
                offer_list=offers_list_new ##
            ) ##
        ) ##
        offers_list.save() ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new)) ##
    for offer_id in is_expired_offers: ##
        offer = Offers.find_one(dict(_id=offer_id)) ##
        try:
            offer.is_expired = True ##
            offer.save()
        except AttributeError:
            continue
示例#3
0
def get_report():
    """
    """
    http = httplib2.Http()
    url_ios = "https://api.taptica.com/v2/bulk?token=O%2fhjVq4UFGiM6fiHJBo2sw%3d%3d&platforms=iPhone"
    url_android = "https://api.taptica.com/v2/bulk?token=O%2fhjVq4UFGiM6fiHJBo2sw%3d%3d&platforms=android"
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json"
    }
    response_ios, content_ios = http.request(url_ios, 'GET', headers=headers)
    response_android, content_android = http.request(url_android,
                                                     'GET',
                                                     headers=headers)
    offers_ios = yajl.loads(content_ios)['Data']
    offers_android = yajl.loads(content_android)['Data']
    offers = offers_ios + offers_android
    offers_list_new = []  ##
    offers_list_old = OfferList.find_one(dict(
        _id=96)).offer_list if OfferList.find_one(dict(_id=96)) else []  ##
    for offer in offers:
        o = Offers(parse_offer(offer))
        re = Offers.find_one(
            dict(title=o.title,
                 geo_targeting=o.geo_targeting,
                 click_url=o.click_url))
        if re:
            offers_list_new.append(re._id)  ##
            re.is_expired = False  ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.package_name = o.package_name
            re.title = o.title
            re.preview_url = o.preview_url
            re.desciption = o.desciption
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.total_cap = o.total_cap
            re.cap = o.cap
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.mini_version = o.mini_version
            re.payment = o.payment
            re.platform = o.platform
            re.geo_targeting = o.geo_targeting
            re.banner_url = o.banner_url
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False  ##
            offers_list_new.append(o._id)  ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=96))  ##
    if offers_list:  ##
        offers_list._id = 96  ##
        offers_list.offer_list = offers_list_new  ##
        offers_list.save()  ##
    else:  ##
        offers_list = OfferList(  ##
            dict(  ##
                _id=96,  ##
                offer_list=offers_list_new  ##
            )  ##
        )  ##
        offers_list.save()  ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new))  ##
    for offer_id in is_expired_offers:  ##
        offer = Offers.find_one(dict(_id=offer_id))  ##
        try:
            offer.is_expired = True  ##
            offer.save()
        except AttributeError:
            continue
示例#4
0
def get_report():
    """
    """
    http = httplib2.Http()
    url = "http://api.c.avazunativeads.com/s2s?sourceid=21804&pagenum=10000&page=1"
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json"
    }
    response, content = http.request(url, 'GET', headers=headers)
    offers = yajl.loads(content)['ads']['ad']
    offers_list_new = [] ##
    offers_list_old = OfferList.find_one(dict(_id=153)).offer_list if OfferList.find_one(dict(_id=153)) else [] ##
    for offer in offers:
        o = Offers(parse_offer(offer))
        re = Offers.find_one(dict(title=o.title, geo_targeting=o.geo_targeting, click_url=o.click_url))
        if re:
            offers_list_new.append(re._id) ##
            re.is_expired = False ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.package_name = o.package_name
            re.title = o.title
            re.desciption = o.desciption
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.total_cap = o.total_cap
            re.cap = o.cap
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.mini_version = o.mini_version
            re.payment = o.payment
            re.platform = o.platform
            re.geo_targeting = o.geo_targeting
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False ##
            offers_list_new.append(o._id) ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=153)) ##
    if offers_list: ##
        offers_list._id = 153 ##
        offers_list.offer_list = offers_list_new ##
        offers_list.save() ##
    else: ##
        offers_list = OfferList( ##
            dict( ##
                _id=153, ##
                offer_list=offers_list_new ##
            ) ##
        ) ##
        offers_list.save() ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new)) ##
    for offer_id in is_expired_offers: ##
        offer = Offers.find_one(dict(_id=offer_id)) ##
        try:
            offer.is_expired = True ##
            offer.save()
        except AttributeError:
            continue
示例#5
0
def get_report():
    """
    """
    http = httplib2.Http()
    url_ios = "https://admin.appnext.com/offerApi.aspx?id=dbc2d386-5f74-4817-a0a6-1b688877ea24"
    url_android = "https://admin.appnext.com/offerApi.aspx?id=cdd8008b-da30-42e3-be36-c64c6bf536ea"
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json"
    }
    response_ios, content_ios = http.request(url_ios, 'GET', headers=headers)
    response_android, content_android = http.request(url_android,
                                                     'GET',
                                                     headers=headers)
    offers_ios = yajl.loads(content_ios)['apps']
    offers_android = yajl.loads(content_android)['apps']
    offers_list_new = []  ##
    offers_list_old = OfferList.find_one(dict(
        _id=111)).offer_list if OfferList.find_one(dict(_id=111)) else []  ##
    for offer in offers_ios:
        o = Offers(parse_ios_offer(offer))
        re = Offers.find_one(
            dict(title=o.title,
                 geo_targeting=o.geo_targeting,
                 click_url=o.click_url))
        if re:
            offers_list_new.append(re._id)  ##
            re.is_expired = False  ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.package_name = o.package_name
            re.title = o.title
            # re.preview_url = o.preview_url
            re.desciption = o.desciption
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.total_cap = o.total_cap
            re.cap = o.cap
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.mini_version = o.mini_version
            re.payment = o.payment
            re.platform = o.platform
            re.geo_targeting = o.geo_targeting
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False  ##
            offers_list_new.append(o._id)  ##
            o.save()

    for offer in offers_android:
        o = Offers(parse_android_offer(offer))
        re = Offers.find_one(
            dict(title=o.title,
                 geo_targeting=o.geo_targeting,
                 click_url=o.click_url))
        if re:
            offers_list_new.append(re._id)  ##
            re.is_expired = False  ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.package_name = o.package_name
            re.title = o.title
            re.preview_url = o.preview_url
            re.desciption = o.desciption
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.total_cap = o.total_cap
            re.cap = o.cap
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.mini_version = o.mini_version
            re.payment = o.payment
            re.platform = o.platform
            re.geo_targeting = o.geo_targeting
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False  ##
            offers_list_new.append(o._id)  ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=111))  ##
    if offers_list:  ##
        offers_list._id = 111  ##
        offers_list.offer_list = offers_list_new  ##
        offers_list.save()  ##
    else:  ##
        offers_list = OfferList(  ##
            dict(  ##
                _id=111,  ##
                offer_list=offers_list_new  ##
            )  ##
        )  ##
        offers_list.save()  ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new))  ##
    for offer_id in is_expired_offers:  ##
        offer = Offers.find_one(dict(_id=offer_id))  ##
        try:
            offer.is_expired = True  ##
            offer.save()
        except AttributeError:
            continue
示例#6
0
def get_report():
    """
    """
    http = httplib2.Http()
    url = "https://api.hasoffers.com/Apiv3/json?NetworkId=adattract&Target=Affiliate_Offer&Method=findMyApprovedOffers&api_key=43bc7b535a0a37560334f2b0aea03783476887b9bd574a6ef5c4ca073e74462d"
    headers = {"Content-Type": "application/json"}
    response, content = http.request(url, 'GET', headers=headers)
    offers = yajl.loads(content)['response']['data']
    offers_list_new = []  ##
    offers_list_old = OfferList.find_one(dict(
        _id=138)).offer_list if OfferList.find_one(dict(_id=138)) else []  ##
    for k, v in offers.iteritems():
        click_url = "https://api.hasoffers.com/Apiv3/json?NetworkId=adattract&Target=Affiliate_Offer&Method=generateTrackingLink&api_key=43bc7b535a0a37560334f2b0aea03783476887b9bd574a6ef5c4ca073e74462d&offer_id=" + str(
            k)
        response, click_url = http.request(click_url, 'GET', headers=headers)
        try:
            click_url = yajl.loads(click_url)['response']['data']['click_url']
        except TypeError:
            continue

        country_url = "https://api.hasoffers.com/Apiv3/json?NetworkId=adattract&Target=Affiliate_Offer&Method=getTargetCountries&api_key=43bc7b535a0a37560334f2b0aea03783476887b9bd574a6ef5c4ca073e74462d&ids%5B%5D=" + str(
            k)
        response, country_url = http.request(country_url,
                                             'GET',
                                             headers=headers)
        try:
            country = yajl.loads(
                country_url)['response']['data'][0]['countries'].keys()
        except AttributeError:
            continue
        platform_url = "https://api.hasoffers.com/Apiv3/json?NetworkId=adattract&Target=Affiliate_OfferTargeting&Method=getRuleTargetingForOffer&api_key=43bc7b535a0a37560334f2b0aea03783476887b9bd574a6ef5c4ca073e74462d&offer_id=" + str(
            k)
        response, platform_url = http.request(platform_url,
                                              'GET',
                                              headers=headers)
        try:
            platform_url = yajl.loads(
                platform_url)['response']['data'][0]['rule']['name']
        except IndexError:
            platform_url = ''
        icon_url = "https://api.hasoffers.com/Apiv3/json?NetworkId=adattract&Target=Affiliate_OfferFile&Method=findAll&api_key=43bc7b535a0a37560334f2b0aea03783476887b9bd574a6ef5c4ca073e74462d&filters%5Boffer_id%5D=" + str(
            k)
        response, icon_banner = http.request(icon_url, 'GET', headers=headers)
        try:
            icon_url = yajl.loads(icon_banner)['response']['data'][
                'data'].values()[0]['OfferFile']['thumbnail']
            banner_url = yajl.loads(icon_banner)['response']['data'][
                'data'].values()[0]['OfferFile']['url']
        except (AttributeError, KeyError, TypeError) as e:
            icon_url = ''
            banner_url = ''
        if platform_url == 'Android':
            platform = '2'
        elif platform_url == 'iOS' or 'iPhone':
            platform = '1'
        else:
            continue
        o = dict(
            advertiser_id=138,
            is_api=True,
            offer_type=1,
            category_id=10,
            title=v['Offer']['name'],
            preview_url=v['Offer']['preview_url'],
            platform=platform,
            click_url=click_url +
            "&transaction_id={clickid}&aff_sub={aff_sub2}&affiliate_id={affid}&aff_sub2={aff_sub1}",  #done
            desciption=cgi.escape(v['Offer']['description']),
            total_cap=10000000,
            day_cap=10000000,
            month_cap=10000000,
            cap=dict(day=10000000, month=10000000, total=10000000),
            payment=float(v['Offer']['default_payout']) * 0.9,
            geo_targeting=country,
            conversions=0,
            revenue=float(v['Offer']['default_payout']),
            status='1',
            access_status='1',
            icon_url=icon_url,
            banner_url=banner_url)
        o = Offers(o)
        re = Offers.find_one(
            dict(title=o.title,
                 geo_targeting=o.geo_targeting,
                 platform=o.platform))  ##
        if re:
            offers_list_new.append(re._id)  ##
            re.is_expired = False  ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.title = o.title
            re.preview_url = o.preview_url
            re.platform = o.platform
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.banner_url = o.banner_url
            re.desciption = o.desciption
            re.total_cap = o.total_cap
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.cap = o.cap
            re.payment = o.payment
            re.geo_targeting = o.geo_targeting
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False  ##
            offers_list_new.append(o._id)  ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=138))  ##
    if offers_list:  ##
        offers_list._id = 138  ##
        offers_list.offer_list = offers_list_new  ##
        offers_list.save()  ##
    else:  ##
        offers_list = OfferList(  ##
            dict(  ##
                _id=138,  ##
                offer_list=offers_list_new  ##
            )  ##
        )  ##
        offers_list.save()  ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new))  ##
    for offer_id in is_expired_offers:  ##
        offer = Offers.find_one(dict(_id=offer_id))  ##
        try:
            offer.is_expired = True  ##
            offer.save()
        except AttributeError:
            continue
示例#7
0
def get_report():
    """
    """
    http = httplib2.Http()
    url = "http://cpactions.com/api/v1.0/feed/public/offers?site_id=10459&hash=bfd486e491d72d38c533af53ee3c47b3097bafed&filters[avg_cr][gt]=0.01"
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json"
    }
    response, content = http.request(url, 'GET', headers=headers)
    offers = yajl.loads(content)['offers']
    offers_list_new = []  ##
    offers_list_old = OfferList.find_one(dict(
        _id=91)).offer_list if OfferList.find_one(dict(_id=91)) else []  ##
    for offer in offers:
        o = Offers(parse_offer(offer))
        re = Offers.find_one(
            dict(title=o.title,
                 geo_targeting=o.geo_targeting,
                 click_url=o.click_url))
        if re:
            offers_list_new.append(re._id)  ##
            re.is_expired = False  ##
            re.advertiser_id = o.advertiser_id
            re.is_api = o.is_api
            re.offer_type = o.offer_type
            re.category_id = o.category_id
            re.package_name = o.package_name
            re.title = o.title
            re.preview_url = o.preview_url
            re.desciption = o.desciption
            re.day_cap = o.day_cap
            re.month_cap = o.month_cap
            re.total_cap = o.total_cap
            re.cap = o.cap
            re.click_url = o.click_url
            re.icon_url = o.icon_url
            re.payment = o.payment
            re.platform = o.platform
            re.geo_targeting = o.geo_targeting
            re.rating = o.rating
            re.conversions = o.conversions
            re.revenue = o.revenue
            re.status = o.status
            re.access_status = o.access_status
            re.save()
        else:
            o._id = _gid('ApiKey')
            o.is_expired = False  ##
            offers_list_new.append(o._id)  ##
            o.save()
    offers_list = OfferList.find_one(dict(_id=91))  ##
    if offers_list:  ##
        offers_list._id = 91  ##
        offers_list.offer_list = offers_list_new  ##
        offers_list.save()  ##
    else:  ##
        offers_list = OfferList(  ##
            dict(  ##
                _id=91,  ##
                offer_list=offers_list_new  ##
            )  ##
        )  ##
        offers_list.save()  ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new))  ##
    for offer_id in is_expired_offers:  ##
        offer = Offers.find_one(dict(_id=offer_id))  ##
        try:
            offer.is_expired = True  ##
            offer.save()
        except AttributeError:
            continue
示例#8
0
def get_report():
    """
    """
    http = httplib2.Http()
    url = "http://feed.appthis.com/feed/v1?api_key=2b749940922e74c65292a6da90e5dc01&format=json"
    headers = {"Content-Type": "application/json"}
    response, content = http.request(url, 'GET', headers=headers)
    offers = yajl.loads(content)['offers']
    offers_list_new = []  ##
    offers_list_old = OfferList.find_one(dict(
        _id=86)).offer_list if OfferList.find_one(dict(_id=86)) else []  ##
    for k, v in offers.iteritems():
        for campaign in v['campaigns']:
            if not v['icon_url'].startswith('http'):
                v['icon_url'] = 'http:' + v['icon_url']
            if campaign['platform'] == 'Android':
                campaign['platform'] = '2'
            if campaign['platform'] == 'iPhone':
                campaign['platform'] = '1'
            o = dict(
                advertiser_id=86,
                is_api=True,
                offer_type=1,
                category_id=10,
                title=v['name'],
                platform=campaign['platform'],
                package_name=v['android_package_name'],
                click_url=v['tracking_url'] +
                "?clickid={clickid}&source={affid}&source2={aff_sub2}",  #done
                icon_url=v['icon_url'],
                desciption=v['description'],
                total_cap=10000000,
                day_cap=10000000,
                month_cap=10000000,
                cap=dict(day=10000000, month=10000000, total=10000000),
                payment=float(campaign['payout']) * 0.9,
                geo_targeting=campaign['countries'],
                conversions=0,
                revenue=float(campaign['payout']),
                status='1',
                access_status='1')
            o = Offers(o)
            re = Offers.find_one(
                dict(title=o.title,
                     geo_targeting=o.geo_targeting,
                     platform=o.platform))
            if re:
                offers_list_new.append(re._id)  ##
                re.is_expired = False  ##
                re.advertiser_id = o.advertiser_id
                re.is_api = o.is_api
                re.offer_type = o.offer_type
                re.category_id = o.category_id
                re.title = o.title
                re.platform = o.platform
                re.package_name = o.package_name
                re.click_url = o.click_url
                re.icon_url = o.icon_url
                re.desciption = o.desciption
                re.total_cap = o.total_cap
                re.day_cap = o.day_cap
                re.month_cap = o.month_cap
                re.cap = o.cap
                re.payment = o.payment
                re.geo_targeting = o.geo_targeting
                re.conversions = o.conversions
                re.revenue = o.revenue
                re.status = o.status
                re.access_status = o.access_status
                re.save()
            else:
                o._id = _gid('ApiKey')
                o.is_expired = False  ##
                offers_list_new.append(o._id)  ##
                o.save()
    offers_list = OfferList.find_one(dict(_id=86))  ##
    if offers_list:  ##
        offers_list._id = 86  ##
        offers_list.offer_list = offers_list_new  ##
        offers_list.save()  ##
    else:  ##
        offers_list = OfferList(  ##
            dict(  ##
                _id=86,  ##
                offer_list=offers_list_new  ##
            )  ##
        )  ##
        offers_list.save()  ##
    is_expired_offers = list(set(offers_list_old) - set(offers_list_new))  ##
    for offer_id in is_expired_offers:  ##
        offer = Offers.find_one(dict(_id=offer_id))  ##
        try:
            offer.is_expired = True  ##
            offer.save()
        except AttributeError:
            continue