示例#1
0
def main():
    r = Reddit('{} hot_sister v3 - /u/{}'.format(settings.NETWORK_NAME,
                                                 settings.USERNAME))
    r.oauth()

    # places multireddit
    places_multi = r.get_multireddit(settings.USERNAME, PLACES_MULTI_NAME)
    places_list_text = ''
    for post in places_multi.get_hot(limit=POSTS_TO_LIST):
        places_list_text += ' * [{}](https://redd.it/{})\n'.format(post.title,
                                                                   post.id)

    # decades multireddit
    decades_multi = r.get_multireddit(settings.USERNAME, DECADES_MULTI_NAME)
    decades_list_text = ''
    for post in decades_multi.get_hot(limit=POSTS_TO_LIST):
        decades_list_text += ' * [{}](https://redd.it/{})\n'.format(post.title,
                                                                    post.id)

    # bring it together
    combined_text = "* Places:\n{}\n\n* Times:\n{}".format(places_list_text,
                                                           decades_list_text)

    # set up all the children
    children = sorted([sub['name'] for sub in settings.CHILD_SUBS])
    for child in children:
        print("running on {}".format(child))
        sub = r.get_subreddit(child)

        current_sidebar = sub.get_settings()['description']
        current_sidebar = html.unescape(current_sidebar)

        # ew
        replace_pattern = re.compile('{}.*?{}'.format(
            re.escape(START_DELIM),
            re.escape(END_DELIM)
        ), re.IGNORECASE | re.DOTALL | re.UNICODE)

        # ew
        new_sidebar = re.sub(
            replace_pattern,
            '{}\\n\\n{}\\n{}'.format(
                START_DELIM,
                combined_text,
                END_DELIM
            ),
            current_sidebar
        )

        try:
            sub.update_settings(description=new_sidebar)
        except HTTPException as e:
            LOG.error(
                "{0} on {1} while updating the sidebar".format(
                    f_e_o(type(e), e)[0], child)
                )
            continue
示例#2
0
def main():
    r = Reddit('{} hot_sister v3 - /u/{}'.format(settings.NETWORK_NAME,
                                                 settings.USERNAME))
    r.oauth()

    # places multireddit
    places_multi = r.get_multireddit(settings.USERNAME, PLACES_MULTI_NAME)
    places_list_text = ''
    for post in places_multi.get_hot(limit=POSTS_TO_LIST):
        places_list_text += ' * [{}](https://redd.it/{})\n'.format(
            post.title, post.id)

    # decades multireddit
    decades_multi = r.get_multireddit(settings.USERNAME, DECADES_MULTI_NAME)
    decades_list_text = ''
    for post in decades_multi.get_hot(limit=POSTS_TO_LIST):
        decades_list_text += ' * [{}](https://redd.it/{})\n'.format(
            post.title, post.id)

    # bring it together
    combined_text = "* Places:\n{}\n\n* Times:\n{}".format(
        places_list_text, decades_list_text)

    # set up all the children
    children = sorted([sub['name'] for sub in settings.CHILD_SUBS])
    for child in children:
        print("running on {}".format(child))
        sub = r.get_subreddit(child)

        current_sidebar = sub.get_settings()['description']
        current_sidebar = html.unescape(current_sidebar)

        # ew
        replace_pattern = re.compile(
            '{}.*?{}'.format(re.escape(START_DELIM), re.escape(END_DELIM)),
            re.IGNORECASE | re.DOTALL | re.UNICODE)

        # ew
        new_sidebar = re.sub(
            replace_pattern,
            '{}\\n\\n{}\\n{}'.format(START_DELIM, combined_text,
                                     END_DELIM), current_sidebar)

        try:
            sub.update_settings(description=new_sidebar)
        except HTTPException as e:
            LOG.error("{0} on {1} while updating the sidebar".format(
                f_e_o(type(e), e)[0], child))
            continue
示例#3
0
def main():
    r = Reddit('{} hot_sister v3 - /u/{}'.format(settings.NETWORK_NAME, settings.USERNAME))
    r.oauth()

    # places multireddit
    places_multi = r.get_multireddit(settings.USERNAME, PLACES_MULTI_NAME)
    places_list_text = str()
    for post in places_multi.get_hot(limit=POSTS_TO_LIST):
        places_list_text += ' * [%s](%s)\n' % (post.title, post.permalink)

    # decades multireddit
    decades_multi = r.get_multireddit(settings.USERNAME, DECADES_MULTI_NAME)
    decades_list_text = str()
    for (i, post) in enumerate(DECADES_MULTI.get_hot(limit=POSTS_TO_LIST)):
        decades_list_text += ' * [%s](%s)\n' % (post.title, post.permalink)

    # bring it together
    combined_text= "* Places:\n{}\n\n* Times:\n{}".format(places_list_text, decades_list_text)

    # set up all the children
    children = sorted([sub['name'] for sub in settings.CHILD_SUBS])
    for child in children:
        print("running on {}".format(child))
        sub = r.get_subreddit(child)

        current_sidebar = sub.get_settings()['description']
        current_sidebar = html.unescape(current_sidebar)

        # ew
        replace_pattern = re.compile('%s.*?%s'.format(
                re.escape(START_DELIM),
                re.escape(END_DELIM)),
            re.IGNORECASE|re.DOTALL|re.UNICODE)

        # ew
        new_sidebar = re.sub(replace_pattern,
                            '{}\\n\\n{}\\n{}'.format(
                                START_DELIM,
                                combinex_text,
                                END_DELIM),
                            current_sidebar)

        sub.update_settings(description=new_sidebar)
示例#4
0
def main():
    r = Reddit('{} hot_sister v3 - /u/{}'.format(settings.NETWORK_NAME,
                                                 settings.USERNAME))
    r.oauth()

    # places multireddit
    places_multi = r.get_multireddit(settings.USERNAME, PLACES_MULTI_NAME)
    places_list_text = str()
    for post in places_multi.get_hot(limit=POSTS_TO_LIST):
        places_list_text += ' * [%s](%s)\n' % (post.title, post.permalink)

    # decades multireddit
    decades_multi = r.get_multireddit(settings.USERNAME, DECADES_MULTI_NAME)
    decades_list_text = str()
    for (i, post) in enumerate(DECADES_MULTI.get_hot(limit=POSTS_TO_LIST)):
        decades_list_text += ' * [%s](%s)\n' % (post.title, post.permalink)

    # bring it together
    combined_text = "* Places:\n{}\n\n* Times:\n{}".format(
        places_list_text, decades_list_text)

    # set up all the children
    children = sorted([sub['name'] for sub in settings.CHILD_SUBS])
    for child in children:
        print("running on {}".format(child))
        sub = r.get_subreddit(child)

        current_sidebar = sub.get_settings()['description']
        current_sidebar = html.unescape(current_sidebar)

        # ew
        replace_pattern = re.compile(
            '%s.*?%s'.format(re.escape(START_DELIM), re.escape(END_DELIM)),
            re.IGNORECASE | re.DOTALL | re.UNICODE)

        # ew
        new_sidebar = re.sub(
            replace_pattern,
            '{}\\n\\n{}\\n{}'.format(START_DELIM, combinex_text,
                                     END_DELIM), current_sidebar)

        sub.update_settings(description=new_sidebar)