mirror of
https://github.com/instaloader/instaloader.git
synced 2024-10-27 05:32:30 +01:00
Merge branch 'master' into upcoming/v4.9
This commit is contained in:
commit
8c752532e1
@ -458,9 +458,12 @@ class Instaloader:
|
|||||||
def save_location(self, filename: str, location: PostLocation, mtime: datetime) -> None:
|
def save_location(self, filename: str, location: PostLocation, mtime: datetime) -> None:
|
||||||
"""Save post location name and Google Maps link."""
|
"""Save post location name and Google Maps link."""
|
||||||
filename += '_location.txt'
|
filename += '_location.txt'
|
||||||
location_string = (location.name + "\n" +
|
if location.lat is not None and location.lng is not None:
|
||||||
"https://maps.google.com/maps?q={0},{1}&ll={0},{1}\n".format(location.lat,
|
location_string = (location.name + "\n" +
|
||||||
location.lng))
|
"https://maps.google.com/maps?q={0},{1}&ll={0},{1}\n".format(location.lat,
|
||||||
|
location.lng))
|
||||||
|
else:
|
||||||
|
location_string = location.name
|
||||||
with open(filename, 'wb') as text_file:
|
with open(filename, 'wb') as text_file:
|
||||||
with BytesIO(location_string.encode()) as bio:
|
with BytesIO(location_string.encode()) as bio:
|
||||||
shutil.copyfileobj(cast(IO, bio), text_file)
|
shutil.copyfileobj(cast(IO, bio), text_file)
|
||||||
|
@ -133,14 +133,15 @@ class NodeIterator(Iterator[T]):
|
|||||||
return item
|
return item
|
||||||
if self._data['page_info']['has_next_page']:
|
if self._data['page_info']['has_next_page']:
|
||||||
query_response = self._query(self._data['page_info']['end_cursor'])
|
query_response = self._query(self._data['page_info']['end_cursor'])
|
||||||
page_index, data = self._page_index, self._data
|
if self._data['edges'] != query_response['edges']:
|
||||||
try:
|
page_index, data = self._page_index, self._data
|
||||||
self._page_index = 0
|
try:
|
||||||
self._data = query_response
|
self._page_index = 0
|
||||||
except KeyboardInterrupt:
|
self._data = query_response
|
||||||
self._page_index, self._data = page_index, data
|
except KeyboardInterrupt:
|
||||||
raise
|
self._page_index, self._data = page_index, data
|
||||||
return self.__next__()
|
raise
|
||||||
|
return self.__next__()
|
||||||
raise StopIteration()
|
raise StopIteration()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -38,8 +38,8 @@ PostLocation.id.__doc__ = "ID number of location."
|
|||||||
PostLocation.name.__doc__ = "Location name."
|
PostLocation.name.__doc__ = "Location name."
|
||||||
PostLocation.slug.__doc__ = "URL friendly variant of location name."
|
PostLocation.slug.__doc__ = "URL friendly variant of location name."
|
||||||
PostLocation.has_public_page.__doc__ = "Whether location has a public page."
|
PostLocation.has_public_page.__doc__ = "Whether location has a public page."
|
||||||
PostLocation.lat.__doc__ = "Latitude (:class:`float`)."
|
PostLocation.lat.__doc__ = "Latitude (:class:`float` or None)."
|
||||||
PostLocation.lng.__doc__ = "Longitude (:class:`float`)."
|
PostLocation.lng.__doc__ = "Longitude (:class:`float` or None)."
|
||||||
|
|
||||||
|
|
||||||
class Post:
|
class Post:
|
||||||
@ -629,7 +629,7 @@ class Post:
|
|||||||
loc.update(self._context.get_json("explore/locations/{0}/".format(location_id),
|
loc.update(self._context.get_json("explore/locations/{0}/".format(location_id),
|
||||||
params={'__a': 1})['native_location_data']['location_info'])
|
params={'__a': 1})['native_location_data']['location_info'])
|
||||||
self._location = PostLocation(location_id, loc['name'], loc['slug'], loc['has_public_page'],
|
self._location = PostLocation(location_id, loc['name'], loc['slug'], loc['has_public_page'],
|
||||||
loc['lat'], loc['lng'])
|
loc.get('lat'), loc.get('lng'))
|
||||||
return self._location
|
return self._location
|
||||||
|
|
||||||
|
|
||||||
@ -1655,7 +1655,7 @@ class TopSearchResults:
|
|||||||
place = location.get('place', {})
|
place = location.get('place', {})
|
||||||
slug = place.get('slug')
|
slug = place.get('slug')
|
||||||
loc = place.get('location', {})
|
loc = place.get('location', {})
|
||||||
yield PostLocation(int(loc['pk']), loc['name'], slug, None, loc['lat'], loc['lng'])
|
yield PostLocation(int(loc['pk']), loc['name'], slug, None, loc.get('lat'), loc.get('lng'))
|
||||||
|
|
||||||
def get_hashtag_strings(self) -> Iterator[str]:
|
def get_hashtag_strings(self) -> Iterator[str]:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user