def setup_function(): Account.clear_cache() Comment.clear_cache() Location.clear_cache() Media.clear_cache() Story.clear_cache() Tag.clear_cache()
def setup_function(): Account.clear_cache() Media.clear_cache() Location.clear_cache() Tag.clear_cache() if not anon["global_delay"] is None: min_delay = anon["global_delay"].get("min", 0) max_delay = anon["global_delay"].get("max", 120) sleep(random() * (max_delay - min_delay) + min_delay)
async def test_async_update_tag(async_agent, settings, name): tag = Tag(name) data = await async_agent.update(tag, settings=settings) assert not data is None assert not tag.name is None assert not tag.media_count is None assert tag.top_posts
async def test_async_get_media_tag(async_agent, delay, settings, count, name): tag = Tag(name) data, pointer = await async_agent.get_media(tag, count=count, delay=delay, settings=settings) assert min(tag.media_count, count) == len(data) assert (pointer is None) == (tag.media_count <= count)
async def test_async_get_media_tag_pointer(async_agent, delay, settings, count, name): tag = Tag(name) pointer = None data = [] for _ in range(count): tmp, pointer = await async_agent.get_media(tag, pointer=pointer, settings=settings) await asyncio.sleep(delay) data.extend(tmp) assert (pointer is None) == (tag.media_count == len(data))
def get_top_hashtag_posts_json(hashtag): agent = None parsedPosts = [] try: agent = WebAgent() hashtag = Tag(hashtag) agent.update(hashtag) posts = agent.get_media(hashtag, count=2)[0] parsedPosts = _get_list_of_parsed_posts(agent, posts, True) except: print("error while getting account info") topHashtagPostsJson = jsonpickle.encode(parsedPosts, unpicklable=False) return topHashtagPostsJson
def test_clear_cache_tag(id): tag = Tag(id) assert Tag.cache == {id: tag} Tag.clear_cache() assert Tag.cache == dict()
import urllib.request import instagram import threading from instagram.agents import WebAgent from instagram.entities import Tag from instagram.entities import Location from instagram.entities import Media base_url = "http://instagram.com/p/" recognition_url = "http://35.228.95.2:5000/calculate?url=" agent = WebAgent() tag = Tag("kek") agent.update(tag) media_list = [] musician_list = [] def check_media(id) -> bool: resp = urllib.request.urlopen(recognition_url + base_url + id).read() print(resp) if resp is "yes": return True #musician_list.append(Musician( ... )) def load_photos(ptr): medias = agent.get_media(tag, count=10, pointer=ptr) for media in medias[0]:
return helloworld_pb2.EmptyMessage() import urllib.request import instagram import threading from instagram.agents import WebAgent from instagram.entities import Tag from instagram.entities import Location from instagram.entities import Media base_url = "http://instagram.com/p/" recognition_url = "http://localhost:5000/calculate?url=" agent = WebAgent() tag = Tag("hearme_musician") agent.update(tag) media_list = [] musician_list = [] def check_media(id) -> bool: print("OPENING request") urll = recognition_url + base_url + id + "/media?size=l" print(urll) resp = urllib.request.urlopen(urll).read() print("request was opended") print(resp) if resp == b'yes':