示例#1
0
def generate(games, prices, system, country):
    country = COUNTRIES[country]

    disabled_urls = False
    disable_full_prices = False

    modifiers = {}

    for modifier in ['unused', 'disable_formatting', 'disable_current_urls', 'disable_new_urls', 'disable_soon_to_expire', 'disable_full_prices']:
        modifiers[modifier] = True

        week_sales, current_sales, total_sales = make_tables(games, prices, system, country, **modifiers)

        size = len(''.join(week_sales)) + len(''.join(current_sales))

        if modifier in ['disable_current_urls', 'disable_new_urls']:
            disabled_urls = True

        if modifier in ['disable_full_prices']:
            disable_full_prices = True

        if size < 39000:
            break

    title = f'{country[FLAG]} {country[ID]} ▪️ Current Nintendo {system} eShop deals'

    content = [
        f'#{country[NAME]}: {total_sales} deals\n'
    ]

    content.extend(header(system, country[ID]))

    if len(week_sales) > 2:
        content.append(f'##Deals of this week: {len(week_sales) - 2} deals\n')
        content.extend(week_sales)
    else:
        content.append('##No new deals :(')

    content.append(SEPARATOR)
    content.append(f'##Active deals: {len(current_sales) - 2} deals\n')
    content.extend(current_sales)

    content.append('')

    if disabled_urls:
        content.append(f'{WARNING} some urls where disable to fit eveything into reddit\'s 40k character limit\n')

    if disable_full_prices:
        content.append(f'{WARNING} full prices where disabled to fit eveything into reddit\'s 40k character limit\n')

    content.append('')

    content.extend(footer(system, country[ID]))

    return title, '\n'.join(content), len(week_sales) - 2, total_sales
示例#2
0
def generate(games, prices, system, country):
    country = COUNTRIES[country]

    week_sales, current_sales, total_sales = make_tables(
        games, prices, system, country)

    disabled_urls = False

    if len(''.join(week_sales)) + len(''.join(current_sales)) > 35000:
        week_sales, current_sales, total_sales = \
            make_tables(games, prices, system, country, disable_current_urls=True)

        disabled_urls = True

    if len(''.join(week_sales)) + len(''.join(current_sales)) > 35000:
        week_sales, current_sales, total_sales = \
            make_tables(games, prices, system, country, disable_current_urls=True, disable_new_urls=True)

        disabled_urls = True

    title = f'{country[FLAG]} {country[ID]} ▪️ Current Nintendo {system} eShop deals'

    content = [f'#{country[NAME]}: {total_sales} deals\n']

    content.extend(header(system, country[ID]))

    if len(week_sales) > 2:
        content.append(f'##Deals of this week: {len(week_sales) - 2} deals\n')
        content.extend(week_sales)
    else:
        content.append('##No new deals :(')

    content.append(SEPARATOR)
    content.append(f'##Active deals: {len(current_sales) - 2} deals\n')
    content.extend(current_sales)

    if disabled_urls:
        content.append('')
        content.append(
            f'{WARNING} some urls where disable to fit eveything into reddit\'s 40k character limit'
        )
        content.append('')

    content.extend(footer(system, country[ID]))

    return title, '\n'.join(content), len(week_sales) - 2, total_sales
示例#3
0
def generate(games, prices, submissions, system):
    title = f'Current Nintendo {system} eShop deals'

    table = make_table(games, prices, system)

    content = []

    content.extend(header())

    content.append(
        '> 💸 👉 PRICES AND SCORES IN THE LINKS AT THE BOTTOM 👈 💸')
    content.append('')

    if table:
        content.append('###Most wanted games on sale')
        content.append('')
        content.append(table)
        content.append(SEPARATOR)

    content.append('###For prices and more check your country/region post')
    content.append(
        f'> *{WARNING} There\'s a known bug on reddit mobile where links won\'t open correctly*'
    )
    content.append('')

    content.append('-|new sales this week|total sales')
    content.append('---|:---:|:---:')

    for country, details in COUNTRIES.items():
        key = f'{system}/{country}'

        submission = submissions.get(key)

        if not submission:
            continue

        content.append(
            f'[{details[FLAG]} {details[NAME]}]({submission.url})|{submission.new_sales}|{submission.total_sales}'
        )

    content.extend(footer())

    return title, '\n'.join(content)
示例#4
0
def generate(games, prices, submissions, system):
    title = f'Current Nintendo {system} eShop deals'

    table = make_table(games, prices, system)

    content = []
    content.extend(header())

    content.append('')
    content.append('⬇ Regional posts with prices, dates, scores, and more.')
    content.append('')
    content.append('-|new sales this week|total sales')
    content.append('---|:---:|:---:')

    for country, details in COUNTRIES.items():
        key = f'{system}/{country}'

        submission = submissions.get(key)

        if not submission:
            continue

        full_url = f'https://www.reddit.com/r/{USER_SUBREDDIT}/comments/{submission.submission_id}'

        content.append(
            f'[{details[FLAG]} {details[NAME]}]({full_url})|{submission.new_sales}|{submission.total_sales}'
        )

    content.append('')

    if table:
        content.append(f'###Most [wishlisted]({WEBSITE_URL}) games on sale')
        content.append('')
        content.append(table)
        content.append(SEPARATOR)

    content.extend(footer())

    return title, '\n'.join(content)
示例#5
0
def generate(games, prices, system, country):
    country = COUNTRIES[country]

    disabled_urls = False
    disable_full_prices = False
    disable_players = False

    modifiers = {}

    for modifier in [
        'unused',
        'disable_title_formatting',
        'disable_current_urls',
        'disable_new_urls',
        'disable_full_prices',
        'disable_players',
        'disable_wishlisted',
        'disable_scores',
        'disable_soon_to_expire',
        'disable_discount_formatting',
        'disable_extra_zeros',
    ]:
        modifiers[modifier] = True

        week_sales, current_sales, total_sales = make_tables(games, prices, system, country, **modifiers)

        size = len(''.join(week_sales)) + len(''.join(current_sales))

        if size < 38000:
            break

    title = f'{country[FLAG]} {country[ID]} ▪️ Current Nintendo {system} eShop deals'

    content = [
        f'#{country[NAME]}: {total_sales} deals\n'
    ]

    content.extend(header(system, country[ID], disable_players=disable_players))

    if len(week_sales) > 2:
        content.append(f'##Deals of this week: {len(week_sales) - 2} deals\n')
        content.extend(week_sales)
    else:
        content.append('##No new deals :(')

    content.append(SEPARATOR)
    content.append(f'##Active deals: {len(current_sales) - 2} deals\n')
    content.extend(current_sales)

    content.append('')

    if any((disabled_urls, disable_full_prices, disable_players)):
        content.append(f'{WARNING} some information is missing to fit eveything into reddit\'s 40k character limit\n')

        content.append('')

        if modifiers.get('disable_current_urls', False):
            content.append('* urls')
        if modifiers.get('disable_full_prices', False):
            content.append('* full prices')
        if modifiers.get('disable_players', False):
            content.append('* number of players')
        if modifiers.get('disable_scores', False):
            content.append('* metacritic scores')

    content.append('')

    content.extend(footer(system, country[ID]))

    return title, '\n'.join(content), len(week_sales) - 2, total_sales