Git Product home page Git Product logo

aiograpi's People

Contributors

dependabot[bot] avatar lucasoeth avatar subzeroid avatar titanmen1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aiograpi's Issues

Force IPV4

Heya just wanna ask, is it possible to force ipv4?

[BUG] 3 validation errors for DirectMessage

pydantic_core._pydantic_core.ValidationError: 3 validation errors for DirectMessage
user_id
Input should be a valid string [type=string_type, input_value=521272456, input_type=int]
For further information visit https://errors.pydantic.dev/2.5/v/string_type
timestamp
Input should be a valid datetime, dates after 9999 are not supported as unix timestamps [type=datetime_parsing, input_value=1709318517654998, input_type=int]
For further information visit https://errors.pydantic.dev/2.5/v/datetime_parsing
clip
Field required [type=missing, input_value={'item_id': '315313612356...4329931787682361376768'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.5/v/missing

[BUG] validation error for Location

This is with the latest git code, as well as 0.0.2 and 0.0.3 releases, trying to retrieve an album. Seems not to be a problem with 0.0.1.

[ERROR@aiograpi] 1 validation error for Location
external_id
  Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='None', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/int_parsing
Traceback (most recent call last):
  File "/path/lib/python3.10/site-packages/aiograpi/mixins/media.py", line 256, in media_info
    media = await self.media_info_gql(media_pk)
  File "/path/lib/python3.10/site-packages/aiograpi/mixins/media.py", line 210, in media_info_gql
    extract_location(data["shortcode_media"]["location"])
  File "/path/lib/python3.10/site-packages/aiograpi/extractors.py", line 305, in extract_location
    return Location(**data)
  File "/path/lib/python3.10/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Location
external_id
  Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='None', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/int_parsing

[BUG] user_follow

Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn

Hello
when trying to follow users, thats what its show now:

FeedbackRequired: feedback_required: Some accounts prefer to manually review followers even when they're public. Let us know if you think we made a mistake.

How to solve it?

[BUG] pydantic v2 HttpUrl data type lacks decode() method and cannot be provided to client.request

Current code gives errors like

AttributeError: 'pydantic_core._pydantic_core.Url' object has no attribute 'decode'

and

TypeError: Invalid type for url.  Expected str or httpx.URL, got <class 'pydantic_core._pydantic_core.Url'>

because pydantic v2 HttpUrl data type lacks string typing from v1. Not sure how to fix but this patch is one fairly inelegant way:

diff -u -r orig/aiograpi/mixins/album.py fixed/aiograpi/mixins/album.py
--- orig/aiograpi/mixins/album.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/album.py	2024-07-08 11:27:32.611526186 -0700
@@ -78,7 +78,7 @@
         """
         paths = []
         for url in urls:
-            file_name = urlparse(url).path.rsplit("/", 1)[1]
+            file_name = urlparse(str(url)).path.rsplit("/", 1)[1]
             if file_name.lower().endswith((".jpg", ".jpeg")):
                 paths.append(await self.photo_download_by_url(url, file_name, folder))
             elif file_name.lower().endswith(".mp4"):
diff -u -r orig/aiograpi/mixins/highlight.py fixed/aiograpi/mixins/highlight.py
--- orig/aiograpi/mixins/highlight.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/highlight.py	2024-07-08 11:28:46.806789891 -0700
@@ -32,7 +32,7 @@
         https://www.instagram.com/stories/highlights/17895485201104054/ -> 17895485201104054
         """
         assert "/highlights/" in url, 'URL must contain "/highlights/"'
-        path = urlparse(url).path
+        path = urlparse(str(url)).path
         parts = [p for p in path.split("/") if p and p.isdigit()]
         return str(parts[0])
 
diff -u -r orig/aiograpi/mixins/photo.py fixed/aiograpi/mixins/photo.py
--- orig/aiograpi/mixins/photo.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/photo.py	2024-07-08 11:33:50.611897231 -0700
@@ -85,10 +85,10 @@
         Path
             Path for the file downloaded
         """
-        fname = urlparse(url).path.rsplit("/", 1)[1]
+        fname = urlparse(str(url)).path.rsplit("/", 1)[1]
         filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname
         path = Path(folder) / filename
-        response = await self.public.get(url)
+        response = await self.public.get(str(url))
         response.raise_for_status()
         with open(path, "wb") as f:
             f.write(response.read())
@@ -107,7 +107,7 @@
         -------
         bytes
         """
-        response = await self.public.get(url)
+        response = await self.public.get(str(url))
         response.raise_for_status()
         return response
 
Only in fixed/aiograpi/mixins: __pycache__
diff -u -r orig/aiograpi/mixins/share.py fixed/aiograpi/mixins/share.py
--- orig/aiograpi/mixins/share.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/share.py	2024-07-08 11:28:35.406180109 -0700
@@ -64,6 +64,6 @@
         str
             Share code
         """
-        path = urlparse(url).path
+        path = urlparse(str(url)).path
         parts = [p for p in path.split("/") if p]
         return parts.pop()
diff -u -r orig/aiograpi/mixins/story.py fixed/aiograpi/mixins/story.py
--- orig/aiograpi/mixins/story.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/story.py	2024-07-08 11:34:04.472249151 -0700
@@ -35,7 +35,7 @@
         https://www.instagram.com/stories/dhbastards/2581281926631793076/
           -> 2581281926631793076
         """
-        path = urlparse(url).path
+        path = urlparse(str(url)).path
         parts = [p for p in path.split("/") if p and p.isdigit()]
         return str(parts[0])
 
@@ -282,12 +282,12 @@
         Path
             Path for the file downloaded
         """
-        fname = urlparse(url).path.rsplit("/", 1)[1].strip()
+        fname = urlparse(str(url)).path.rsplit("/", 1)[1].strip()
         if not fname:
             raise Exception("The URL must contain the path to the file (mp4 or jpg)")
         filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname
         path = Path(folder) / filename
-        response = await self.public.get(url)
+        response = await self.public.get(str(url))
         response.raise_for_status()
         with open(path, "wb") as f:
             f.write(response.read())
diff -u -r orig/aiograpi/mixins/track.py fixed/aiograpi/mixins/track.py
--- orig/aiograpi/mixins/track.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/track.py	2024-07-08 11:29:29.219155870 -0700
@@ -28,7 +28,7 @@
         Path
             Path for the file downloaded
         """
-        fname = urlparse(url).path.rsplit("/", 1)[1].strip()
+        fname = urlparse(str(url)).path.rsplit("/", 1)[1].strip()
         if not fname:
             raise Exception("The URL must contain the path to the file (m4a or mp3).")
         filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname
diff -u -r orig/aiograpi/mixins/video.py fixed/aiograpi/mixins/video.py
--- orig/aiograpi/mixins/video.py	2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/mixins/video.py	2024-07-08 11:34:19.302616942 -0700
@@ -80,10 +80,10 @@
         Path
             Path for the file downloaded
         """
-        fname = urlparse(url).path.rsplit("/", 1)[1]
+        fname = urlparse(str(url)).path.rsplit("/", 1)[1]
         filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname
         path = Path(folder) / filename
-        response = await self.public.get(url)
+        response = await self.public.get(str(url))
         response.raise_for_status()
         content_length = int(response.headers.get("Content-Length"))
         file_length = len(response.content)
@@ -110,7 +110,7 @@
         bytes
             Bytes for the file downloaded
         """
-        response = await self.public.get(url)
+        response = await self.public.get(str(url))
         response.raise_for_status()
         content_length = int(response.headers.get("Content-Length"))
         file_length = len(response.content)

[BUG] direct_threads problem

there's a problem when I try to fetch direct threads data, here is my code:

from aiograpi import Client
import asyncio

async def main():
    cl = Client()
    await cl.login_by_sessionid('58645505882%3AmkhWjhRsu5qmO2%3A2%3AAYfIKzEyqrTdIkag_yHxodIhBSeDD3oE6r1S0z7Oog')
    thread = (await cl.direct_threads(1))[0]
    print(thread.pk)
if __name__ == '__main__':
    asyncio.run(main())

and here is the Error I got:

Traceback (most recent call last):
  File "d:\VisualStudio\DirectMessageAsyncrouns\aiograp.py", line 10, in <module>
    asyncio.run(main())
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "d:\VisualStudio\DirectMessageAsyncrouns\aiograp.py", line 7, in main
    thread = (await cl.direct_threads(1))[0]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiograpi\mixins\direct.py", line 90, in direct_threads
    threads.append(extract_direct_thread(thread))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiograpi\extractors.py", line 347, in extract_direct_thread
    return DirectThread(**data)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydantic\main.py", line 175, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for DirectThread
last_activity_at
  Input should be a valid datetime, dates after 9999 are not supported as unix timestamps [type=datetime_parsing, input_value=1714209379485000, input_type=int]    For further information visit https://errors.pydantic.dev/2.7/v/datetime_parsing

[BUG] Example not working

Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn

Describe the bug
Running the README example simply just don't work.

To Reproduce

from aiograpi import Client

ACCOUNT_USERNAME = "myuser"
ACCOUNT_PASSWORD = "mypassword"

cl = Client()
await cl.login(ACCOUNT_USERNAME, ACCOUNT_PASSWORD)

user_id = await cl.user_id_from_username(ACCOUNT_USERNAME)
medias = await cl.user_medias(user_id, 20)

Traceback

Screenshot from 2024-05-24 16-18-54

Expected behavior
A working Script

Screenshots
Show above...

Desktop (please complete the following information):

  • OS: Pop OS 22.04 LTS
  • Python version 3.10
  • aiograpi version 0.03

Additional context
I'm just getting familiar with the API so a more descriptive error would be very beneficial.

BUG while using user_followers() code expample: followers = await cl.user_followers(cl.user_id)

Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn

Describe the bug
followers = await cl.user_followers(cl.user_id)
when using the above function im getting the below error message in the output

To Reproduce
followers = await cl.user_followers(cl.user_id)

Traceback
Show your full traceback so that it is clear where exactly the error occurred.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Output
Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/username/?__a=1&__d=dis) >>>
'NoneType' object has no attribute 'cookies'
Traceback (most recent call last):
File "D:\Projects\Python\raph\venv\Lib\site-packages\aiograpi\mixins\user.py", line 891, in user_followers
users = await self.user_followers_gql(user_id, amount)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Projects\Python\raph\venv\Lib\site-packages\aiograpi\mixins\user.py", line 780, in user_followers_gql
items, end_cursor = await self.user_followers_gql_chunk(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Projects\Python\raph\venv\Lib\site-packages\aiograpi\mixins\user.py", line 732, in user_followers_gql_chunk
self.inject_sessionid_to_public()
File "D:\Projects\Python\raph\venv\Lib\site-packages\aiograpi\mixins\auth.py", line 851, in inject_sessionid_to_public
self.graphql.set_cookies(cookie)
File "D:\Projects\Python\raph\venv\Lib\site-packages\aiograpi\reqwests.py", line 87, in set_cookies
self._client.cookies.set(k, v)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cookies'

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 21.04]
  • Python version [e.g. 3.8.3]
  • aiograpi version [e.g. 1.9.3, not "latest"]
  • moveipy version if used
  • imagemagick version if used

Additional context
Add any other context about the problem here.

[BUG] Not awaited several methods in method photo_upload

Describe the bug
I tried to publish media post with 1 photo. I called method photo_upload. But got error in line aiograpi.mixins.photo.UploadPhotoMixin.photo_upload:239 Media is None. I found out that method photo_configure isn't await, it's reason why media is None.
And also method expose not awaited in method photo_upload
And also method location_build not awaited in method photo_configure

To Reproduce
Just call method photo_upload. As is

Traceback
File "/Users/artem_arkhipov/projects/pygmalion/robo-blogger/robo_blogger/worker/publishers/post_publisher.py", line 10, in publish posted_photo = await self.session._client.photo_upload( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/artem_arkhipov/Library/Caches/pypoetry/virtualenvs/robo-blogger-lGCq8Q3n-py3.11/lib/python3.11/site-packages/aiograpi/mixins/photo.py", line 239, in photo_upload return extract_media_v1(media) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/artem_arkhipov/Library/Caches/pypoetry/virtualenvs/robo-blogger-lGCq8Q3n-py3.11/lib/python3.11/site-packages/aiograpi/extractors.py", line 44, in extract_media_v1 if versions := media.get("video_versions", []): ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'
Expected behavior
I expected that photo will publish

aiograpi ==0.0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.