diff --git a/src/api.nim b/src/api.nim index 44a69a9..9c033c0 100644 --- a/src/api.nim +++ b/src/api.nim @@ -50,7 +50,8 @@ proc getMediaTimeline*(id: string; after=""): Future[Timeline] {.async.} = result = parseTimeline(await fetch(url), after) proc getPhotoRail*(id: string): Future[PhotoRail] {.async.} = - result = parsePhotoRail(await getMediaTimeline(id)) + let url = mediaTimeline / (id & ".json") ? genParams() + result = parsePhotoRail(await fetch(url)) proc getSearch*[T](query: Query; after=""): Future[Result[T]] {.async.} = when T is Profile: diff --git a/tests/base.py b/tests/base.py index efa1441..22bbb86 100644 --- a/tests/base.py +++ b/tests/base.py @@ -53,6 +53,7 @@ class Timeline(object): end = '.timeline-end' none = '.timeline-none' protected = '.timeline-protected' + photo_rail = '.photo-rail-grid' class Conversation(object): diff --git a/tests/test_timeline.py b/tests/test_timeline.py index e3000c4..dd78396 100644 --- a/tests/test_timeline.py +++ b/tests/test_timeline.py @@ -12,6 +12,13 @@ empty = [['emptyuser'], ['mobile_test_10']] protected = [['mobile_test_7'], ['Empty_user']] +photo_rail = [['mobile_test', [ + 'BzUnaDFCUAAmrjs', 'Bo0nDsYIYAIjqVn', 'Bos--KNIQAAA7Li', 'Boq1sDJIYAAxaoi', + 'BonISmPIEAAhP3G', 'BoQbwJAIUAA0QCY', 'BoQbRQxIIAA3FWD', 'Bn8Qh8iIIAABXrG', + 'Bn8QIG3IYAA0IGT', 'Bn8O3QeIUAAONai', 'Bn8NGViIAAATNG4', 'BkKovdrCUAAEz79', + 'BkKoe_oCIAASAqr', 'BkKoRLNCAAAYfDf', 'BkKndxoCQAE1vFt', 'BPEmIbYCMAE44dl' +]]] + class TweetTest(BaseTestCase): @parameterized.expand(normal) @@ -52,3 +59,11 @@ class TweetTest(BaseTestCase): self.assert_element_absent(Timeline.newest) self.assert_element_absent(Timeline.older) self.assert_element_absent(Timeline.end) + + @parameterized.expand(photo_rail) + def test_photo_rail(self, username, images): + self.open_nitter(username) + self.assert_element_visible(Timeline.photo_rail) + for i, url in enumerate(images): + img = self.get_attribute(Timeline.photo_rail + f' a:nth-child({i + 1}) img', 'src') + self.assertIn(url, img)