Esempio n. 1
0
def get_author_id():
    logger.info("Running get_author_id()")
    link_id = ifl.get_author_id('https://ifunny.co/user/Scum')
    # print(link_id)
    temp_post = ifl.post_from_url(
        'https://ifunny.co/picture/dorit-girlfriend-ordering-my-starbucks-drink-XW5wI8bt7?gallery=user&query=Scum'
    )
    print(temp_post.creator_id)
    searched = ifl.get_author_id("scum", search_limit=3)
    assert link_id == temp_post.creator_id == searched[0][0]
    print("All three methods to get author id give the same id")
def archive_user(username):
    author = ifl.User(ifl.get_author_id(username))
    goto_dir(author.name)
    print('saving main data.')
    author.store_file(author.name + ".txt")
    print('done.')
    print("loading subscribtions.")
    author.subscriptions.tag_only_mode = "nick"
    author.subscriptions.load()
    print('saving.')
    author.subscriptions.save_to_file("subscriptions.txt")
    print("done.")
    print('loading subscribers')
    author.subscribers.tag_only_mode = "nick"
    author.subscribers.load()
    print('saving.')
    author.subscribers.save_to_file("subscribers.txt")
    print('done.')
    print('loading posts.')
    author.posts.load()
    temp_len = len(author.posts)
    count = 40
    for num_a, a in enumerate(author.posts):
        if count > 0:
            count -= 1
            continue
        now = time.time()
        if "id" not in a.errored_attributes:
            print(f'saving {a.id}: {num_a}/{temp_len}')
            goto_dir(a.id)
            ifl.dl_from_link(a.url, "Content." + a.url.split('.')[-1])
            a.store_file("Post data.txt")
            print('smiles')
            a.smiles.tag_only_mode = 'nick'
            a.smiles.load()
            a.smiles.save_to_file("smiles.txt")
            print('repubs')
            a.repubs.tag_only_mode = 'nick'
            a.repubs.load()
            a.repubs.save_to_file("repubs.txt")
            print('comments')
            a.comments.load()
            out = ""
            for b in a.comments:
                try:
                    out += b.name + ': ' + b.text + '\n'
                except:
                    out += "[removed]\n"
                b.replies.load()
                for c in b.replies:
                    try:
                        out += '   '*c.depth + c.creator_id + ': ' + c.text + '\n'
                    except:
                        out += '   '*c.depth + '[removed]\n'
            with open('Comments.txt', 'w', encoding="utf-16") as f:
                f.write(out)
            os.chdir('..')
            print(time.time() - now)
    print('done.')
Esempio n. 3
0
def basic_queue_loading():
    logger.info('Running basic_queue_loading()')
    # first need to replace important code, and then test new Queue functionality
    author_id = ifl.get_author_id("timebomb69882timebomb6988")
    author_obj = ifl.User(author_id)
    post_queue = ifl.Queue(ifl.Post, author_obj.endpoints['posts'])
    post_queue.load()
    # print(len(post_queue.stored_content))
    for a in post_queue:
        # print(a)
        pass
Esempio n. 4
0
def auth_info():
    logger.info("Running auth_info()")
    id = ifl.get_author_id("GodDammitJim_2016")
    author = ifl.User(id)
    # print(type(User.raw_data))
    author.posts.load(2)
    assert len(author.posts) == 2
    author.posts.chunks = 100  # by setting chunks to 100, we reach ~100 posts/s
    author.posts.load(limit=2)
    assert len(author.posts) > 3
    # print(len(author.posts))
    # pprint(author.posts[0].cdata)
    print(
        'Gets author info and loads the first visible posts (incomplete test)')
Esempio n. 5
0
def user_vs_account():
    logger.info("Running user_vs_account()")

    author_id = ifl.get_author_id("namisboss")
    response = ifl.api_call(
        url=f"https://api.ifunny.mobi/v4/users/{author_id}",
        auth=ifl.BEARER_TOKEN,
        params={"limit": 1})
    # pprint(author_id)

    # todo see if there is any more info to be gotten for indirectly blocked users, ask for it on devs
    # Faicial id: 579c41d36d9c4dc9188b4591
    # Scrum id: 5468586e4c4fd0d9688b456a
    # auth_response = ifl.api_call(url="https://api.ifunny.mobi/v4/map", auth=ifl.BEARER_TOKEN, params={'lat1': -90, 'lat2': 90, "lon1": -180, "lon2": 180, 'limit': 2})
    auth_response = ifl.api_call(url=f"https://api.ifunny.mobi/v4/account",
                                 auth=ifl.BEARER_TOKEN,
                                 params={'limit': 100})
    # pprint(auth_response)
    assert response == auth_response
    print('User call returns the same data as account info')
Esempio n. 6
0
def get_subscriptions():
    logger.info("Running get_subscriptoins()")

    # this code was used to visually compare user data from subscriptions list and user object
    #
    author_id = ifl.get_author_id("namisboss")
    user = ifl.User(creator_id=author_id)
    user.subscriptions.load(2)
    response = ifl.api_call(
        url=f"https://api.ifunny.mobi/v4/users/{author_id}/subscriptions",
        auth=ifl.BASIC_TOKEN,
        params={"limit": 1})
    # sub_author_id = ifl.get_author_id("PoliticallyincorrectAPOI")
    sub_author_id = "51cb699bc573a4904eb0a0be"
    sub_author = ifl.User(sub_author_id)
    # pprint(response["data"]["users"]["items"])
    # pprint(sub_author.cdata)
    # pprint(user.subscriptions[0].cdata)
    assert sub_author.cdata == user.subscriptions[0].cdata
    print("Correctly gets my first subscription")