InstaloaderContext class for log and low-level IO
This commit is contained in:
parent
8623829696
commit
c350847b50
925
instaloader.py
925
instaloader.py
File diff suppressed because it is too large
Load Diff
@ -25,10 +25,10 @@ class TestInstaloader(unittest.TestCase):
|
|||||||
self.L = instaloader.Instaloader(download_geotags=instaloader.Tristate.always,
|
self.L = instaloader.Instaloader(download_geotags=instaloader.Tristate.always,
|
||||||
download_comments=instaloader.Tristate.always,
|
download_comments=instaloader.Tristate.always,
|
||||||
save_metadata=instaloader.Tristate.always)
|
save_metadata=instaloader.Tristate.always)
|
||||||
self.L.raise_all_errors = True
|
self.L.context.raise_all_errors = True
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.L.session.close()
|
self.L.close()
|
||||||
os.chdir('/')
|
os.chdir('/')
|
||||||
print("Removing {}".format(self.dir))
|
print("Removing {}".format(self.dir))
|
||||||
shutil.rmtree(self.dir)
|
shutil.rmtree(self.dir)
|
||||||
@ -40,14 +40,12 @@ class TestInstaloader(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.SkipTest
|
@unittest.SkipTest
|
||||||
def test_stories_download(self):
|
def test_stories_download(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
self.L.download_stories()
|
self.L.download_stories()
|
||||||
|
|
||||||
@unittest.SkipTest
|
@unittest.SkipTest
|
||||||
def test_private_profile_download(self):
|
def test_private_profile_download(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
self.L.download_profile(PRIVATE_PROFILE, download_stories=True)
|
self.L.download_profile(PRIVATE_PROFILE, download_stories=True)
|
||||||
|
|
||||||
def test_profile_pic_download(self):
|
def test_profile_pic_download(self):
|
||||||
@ -57,45 +55,38 @@ class TestInstaloader(unittest.TestCase):
|
|||||||
self.L.download_hashtag(HASHTAG, NORMAL_MAX_COUNT)
|
self.L.download_hashtag(HASHTAG, NORMAL_MAX_COUNT)
|
||||||
|
|
||||||
def test_feed_download(self):
|
def test_feed_download(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
self.L.download_feed_posts(NORMAL_MAX_COUNT)
|
self.L.download_feed_posts(NORMAL_MAX_COUNT)
|
||||||
|
|
||||||
def test_feed_paging(self):
|
def test_feed_paging(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
for count, post in enumerate(self.L.get_feed_posts()):
|
for count, post in enumerate(self.L.get_feed_posts()):
|
||||||
print(post)
|
print(post)
|
||||||
if count == PAGING_MAX_COUNT:
|
if count == PAGING_MAX_COUNT:
|
||||||
break
|
break
|
||||||
|
|
||||||
def test_saved_download(self):
|
def test_saved_download(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
self.L.download_saved_posts(NORMAL_MAX_COUNT)
|
self.L.download_saved_posts(NORMAL_MAX_COUNT)
|
||||||
|
|
||||||
def test_saved_paging(self):
|
def test_saved_paging(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
for count, post in enumerate(instaloader.Profile(self.L.context, OWN_USERNAME).get_saved_posts()):
|
||||||
for count, post in enumerate(instaloader.Profile(self.L, OWN_USERNAME).get_saved_posts()):
|
|
||||||
print(post)
|
print(post)
|
||||||
if count == PAGING_MAX_COUNT:
|
if count == PAGING_MAX_COUNT:
|
||||||
break
|
break
|
||||||
|
|
||||||
def test_test_login(self):
|
def test_test_login(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
self.assertEqual(OWN_USERNAME, self.L.test_login())
|
self.assertEqual(OWN_USERNAME, self.L.test_login())
|
||||||
|
|
||||||
def test_get_followees(self):
|
def test_get_followees(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
for f in self.L.get_followees(OWN_USERNAME):
|
for f in self.L.get_followees(OWN_USERNAME):
|
||||||
print(f['username'])
|
print(f['username'])
|
||||||
|
|
||||||
def test_get_followers(self):
|
def test_get_followers(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
|
||||||
for f in self.L.get_followers(OWN_USERNAME):
|
for f in self.L.get_followers(OWN_USERNAME):
|
||||||
print(f['username'])
|
print(f['username'])
|
||||||
|
|
||||||
@ -106,16 +97,15 @@ class TestInstaloader(unittest.TestCase):
|
|||||||
self.assertEqual(PUBLIC_PROFILE_ID, self.L.get_id_by_username(PUBLIC_PROFILE))
|
self.assertEqual(PUBLIC_PROFILE_ID, self.L.get_id_by_username(PUBLIC_PROFILE))
|
||||||
|
|
||||||
def test_get_likes(self):
|
def test_get_likes(self):
|
||||||
if not self.L.is_logged_in:
|
self.L.load_session_from_file(OWN_USERNAME)
|
||||||
self.L.load_session_from_file(OWN_USERNAME)
|
for post in instaloader.Profile(self.L.context, OWN_USERNAME).get_posts():
|
||||||
for post in instaloader.Profile(self.L, OWN_USERNAME).get_posts():
|
|
||||||
for like in post.get_likes():
|
for like in post.get_likes():
|
||||||
print(like['username'])
|
print(like['username'])
|
||||||
break
|
break
|
||||||
|
|
||||||
def test_post_from_mediaid(self):
|
def test_post_from_mediaid(self):
|
||||||
for post in instaloader.Profile(self.L, PUBLIC_PROFILE).get_posts():
|
for post in instaloader.Profile(self.L.context, PUBLIC_PROFILE).get_posts():
|
||||||
post2 = instaloader.Post.from_mediaid(self.L, post.mediaid)
|
post2 = instaloader.Post.from_mediaid(self.L.context, post.mediaid)
|
||||||
self.assertEqual(post, post2)
|
self.assertEqual(post, post2)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user