interpals-api 2.2.1__tar.gz → 2.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. interpals_api-2.3.1/PKG-INFO +192 -0
  2. interpals_api-2.3.1/interpals_api/__init__.py +161 -0
  3. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/api.py +189 -38
  4. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/cookie.py +15 -5
  5. interpals_api-2.3.1/interpals_api/errors.py +65 -0
  6. interpals_api-2.3.1/interpals_api/parsers/__init__.py +3 -0
  7. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/parsers/chat_parser.py +43 -9
  8. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/parsers/friends_parser.py +20 -1
  9. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/parsers/pictures_parser.py +32 -3
  10. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/parsers/profile_parser.py +20 -1
  11. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api/session.py +53 -7
  12. interpals_api-2.3.1/interpals_api/utils.py +23 -0
  13. interpals_api-2.3.1/interpals_api.egg-info/PKG-INFO +192 -0
  14. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api.egg-info/SOURCES.txt +0 -1
  15. interpals_api-2.3.1/interpals_api.egg-info/requires.txt +4 -0
  16. interpals_api-2.3.1/setup.py +42 -0
  17. interpals-api-2.2.1/PKG-INFO +0 -167
  18. interpals-api-2.2.1/interpals_api/__init__.py +0 -2
  19. interpals-api-2.2.1/interpals_api/errors.py +0 -34
  20. interpals-api-2.2.1/interpals_api/parsers/__init__.py +0 -0
  21. interpals-api-2.2.1/interpals_api/request.py +0 -43
  22. interpals-api-2.2.1/interpals_api/utils.py +0 -12
  23. interpals-api-2.2.1/interpals_api.egg-info/PKG-INFO +0 -167
  24. interpals-api-2.2.1/interpals_api.egg-info/requires.txt +0 -5
  25. interpals-api-2.2.1/setup.py +0 -26
  26. {interpals-api-2.2.1 → interpals_api-2.3.1}/README.md +0 -0
  27. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api.egg-info/dependency_links.txt +0 -0
  28. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api.egg-info/not-zip-safe +0 -0
  29. {interpals-api-2.2.1 → interpals_api-2.3.1}/interpals_api.egg-info/top_level.txt +0 -0
  30. {interpals-api-2.2.1 → interpals_api-2.3.1}/setup.cfg +0 -0
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: interpals-api
3
+ Version: 2.3.1
4
+ Summary: Unofficial Python API for Interpals.net.
5
+ Home-page: https://github.com/fomalhaut88/interpals-api
6
+ Author: Alexander Khlebushchev
7
+ License: MIT
8
+ Project-URL: Homepage, https://pypi.org/project/interpals-api/
9
+ Project-URL: Documentation, https://fomalhaut88.github.io/interpals-api/
10
+ Project-URL: Source, https://github.com/fomalhaut88/interpals-api
11
+ Project-URL: Issues, https://github.com/fomalhaut88/interpals-api/issues
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Internet :: WWW/HTTP
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: aiohttp>=3.12
22
+ Requires-Dist: requests>=2.32
23
+ Requires-Dist: lxml>=6.0
24
+ Requires-Dist: beautifulsoup4>=4.13
25
+ Dynamic: author
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # interpals-api
37
+
38
+ This Python library provides a simple HTTP API for working with the website https://interpals.net/. It includes:
39
+
40
+ * retrieving data by user identifier
41
+ * listing visitors
42
+ * searching for users by criterions
43
+ * viewing and sending messages, deleting chats
44
+ * listing, adding and removing friends
45
+ * listing albums and pictures
46
+
47
+ ## Installation
48
+
49
+ ```
50
+ pip install interpals-api
51
+ ```
52
+
53
+ ## Basic example
54
+
55
+ ```python
56
+ from interpals_api import Session, Api
57
+
58
+ session = Session.login('yourusername', 'yourpassword')
59
+ api = Api(session)
60
+
61
+ user_info = api.profile('someuser')
62
+ print(user_info)
63
+ ```
64
+
65
+ Since version `2.1` it supports asynchronous calls for each api method. Below there is a brief asynchonous example:
66
+
67
+ ```python
68
+ from interpals_api import SessionAsync, ApiAsync
69
+
70
+ session = await SessionAsync.login('yourusername', 'yourpassword')
71
+ api = ApiAsync(session)
72
+
73
+ user_info = await api.profile('someuser')
74
+ print(user_info)
75
+ ```
76
+
77
+ ## Other examples
78
+
79
+ Basic example to retrieve user info:
80
+
81
+ ```python
82
+ from interpals_api import Session, Api
83
+
84
+ session = Session.login('yourusername', 'yourpassword')
85
+ api = Api(session)
86
+
87
+ # This gives info of the user with the link: https://www.interpals.net/someuser
88
+ user_info = api.profile('someuser')
89
+ ```
90
+
91
+ Dump and load session object:
92
+
93
+ ```python
94
+ from interpals_api import Session, Api
95
+
96
+ session = Session.login('yourusername', 'yourpassword')
97
+
98
+ # Save session into a file
99
+ with open('session.json', 'w') as f:
100
+ session.dump(f)
101
+
102
+ # Load session from the saved file
103
+ with open('session.json') as f:
104
+ session = Session.load(f)
105
+ ```
106
+
107
+ Viewing and searching for users:
108
+
109
+ ```python
110
+ from interpals_api import Session, Api
111
+
112
+ session = Session.login('yourusername', 'yourpassword')
113
+ api = Api(session)
114
+
115
+ # Viewing a certain user
116
+ api.view('someuser')
117
+
118
+ # Showing the visitors of your profile
119
+ users = api.visitors()
120
+ print(users)
121
+
122
+ # Searching for users
123
+ options = {
124
+ 'age1': '20',
125
+ 'age2': '40',
126
+ 'sex': ['male', 'female'],
127
+ 'continents': ['AF', 'AS', 'EU', 'NA', 'OC', 'SA'],
128
+ 'countries': ['US', 'CA', 'UK', 'RU'],
129
+ 'keywords': 'travelling',
130
+ 'online': True,
131
+ 'cityName': 'London' # Or you can use 'city' with its direct code on the website (it's faster)
132
+ }
133
+ for user in api.search(options, limit=100, timeout=1.0):
134
+ print(user)
135
+ ```
136
+
137
+ To work with friends and pictures, it is necessary to use `uid` in methods:
138
+
139
+ ```python
140
+ from interpals_api import Session, Api
141
+
142
+ session = Session.login('yourusername', 'yourpassword')
143
+ api = Api(session)
144
+
145
+ uid = api.get_uid('someuser')
146
+
147
+ # Listing friends of the user 'someuser'
148
+ friends = api.friends(uid)
149
+ print(friends)
150
+
151
+ # Adding 'someuser' to friends
152
+ api.friend_add(uid)
153
+
154
+ # Removing 'someuser' from friends
155
+ api.friend_remove(uid)
156
+
157
+ # Listing pictures
158
+ albums = api.albums(uid)
159
+ for album in albums:
160
+ aid = album['aid']
161
+ pictures = api.pictures(uid, aid)
162
+ for picture in pictures:
163
+ print(picture['src'])
164
+ ```
165
+
166
+ Working with the chat is done through `thread_id`:
167
+
168
+ ```python
169
+ from interpals_api import Session, Api
170
+
171
+ session = Session.login('yourusername', 'yourpassword')
172
+ api = Api(session)
173
+
174
+ uid = api.get_uid('someuser')
175
+
176
+ # Listing your chats
177
+ result = api.chat(count=9, offset=0)
178
+ print(result['chats'])
179
+
180
+ # Staring new chat (getting thread_id)
181
+ thread_id = api.get_thread_id(uid)
182
+
183
+ # Show chat messages
184
+ messages = api.chat_messages(thread_id)
185
+ print(messages)
186
+
187
+ # Send new message to the thread
188
+ api.chat_send(thread_id, "Hey! How are you?")
189
+
190
+ # Removing chat
191
+ api.chat_delete(thread_id)
192
+ ```
@@ -0,0 +1,161 @@
1
+ """
2
+ This Python library provides a simple HTTP API for working with the website https://interpals.net/. It includes:
3
+
4
+ * retrieving data by user identifier
5
+ * listing visitors
6
+ * searching for users by criterions
7
+ * viewing and sending messages, deleting chats
8
+ * listing, adding and removing friends
9
+ * listing albums and pictures
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ pip install interpals-api
15
+ ```
16
+
17
+ ## Basic example
18
+
19
+ ```python
20
+ from interpals_api import Session, Api
21
+
22
+ session = Session.login('yourusername', 'yourpassword')
23
+ api = Api(session)
24
+
25
+ user_info = api.profile('someuser')
26
+ print(user_info)
27
+ ```
28
+
29
+ Since version `2.1` it supports asynchronous calls for each api method. Below there is a brief asynchonous example:
30
+
31
+ ```python
32
+ from interpals_api import SessionAsync, ApiAsync
33
+
34
+ session = await SessionAsync.login('yourusername', 'yourpassword')
35
+ api = ApiAsync(session)
36
+
37
+ user_info = await api.profile('someuser')
38
+ print(user_info)
39
+ ```
40
+
41
+ ## Other examples
42
+
43
+ Basic example to retrieve user info:
44
+
45
+ ```python
46
+ from interpals_api import Session, Api
47
+
48
+ session = Session.login('yourusername', 'yourpassword')
49
+ api = Api(session)
50
+
51
+ # This gives info of the user with the link: https://www.interpals.net/someuser
52
+ user_info = api.profile('someuser')
53
+ ```
54
+
55
+ Dump and load session object:
56
+
57
+ ```python
58
+ from interpals_api import Session, Api
59
+
60
+ session = Session.login('yourusername', 'yourpassword')
61
+
62
+ # Save session into a file
63
+ with open('session.json', 'w') as f:
64
+ session.dump(f)
65
+
66
+ # Load session from the saved file
67
+ with open('session.json') as f:
68
+ session = Session.load(f)
69
+ ```
70
+
71
+ Viewing and searching for users:
72
+
73
+ ```python
74
+ from interpals_api import Session, Api
75
+
76
+ session = Session.login('yourusername', 'yourpassword')
77
+ api = Api(session)
78
+
79
+ # Viewing a certain user
80
+ api.view('someuser')
81
+
82
+ # Showing the visitors of your profile
83
+ users = api.visitors()
84
+ print(users)
85
+
86
+ # Searching for users
87
+ options = {
88
+ 'age1': '20',
89
+ 'age2': '40',
90
+ 'sex': ['male', 'female'],
91
+ 'continents': ['AF', 'AS', 'EU', 'NA', 'OC', 'SA'],
92
+ 'countries': ['US', 'CA', 'UK', 'RU'],
93
+ 'keywords': 'travelling',
94
+ 'online': True,
95
+ 'cityName': 'London' # Or you can use 'city' with its direct code on the website (it's faster)
96
+ }
97
+ for user in api.search(options, limit=100, timeout=1.0):
98
+ print(user)
99
+ ```
100
+
101
+ To work with friends and pictures, it is necessary to use `uid` in methods:
102
+
103
+ ```python
104
+ from interpals_api import Session, Api
105
+
106
+ session = Session.login('yourusername', 'yourpassword')
107
+ api = Api(session)
108
+
109
+ uid = api.get_uid('someuser')
110
+
111
+ # Listing friends of the user 'someuser'
112
+ friends = api.friends(uid)
113
+ print(friends)
114
+
115
+ # Adding 'someuser' to friends
116
+ api.friend_add(uid)
117
+
118
+ # Removing 'someuser' from friends
119
+ api.friend_remove(uid)
120
+
121
+ # Listing pictures
122
+ albums = api.albums(uid)
123
+ for album in albums:
124
+ aid = album['aid']
125
+ pictures = api.pictures(uid, aid)
126
+ for picture in pictures:
127
+ print(picture['src'])
128
+ ```
129
+
130
+ Working with the chat is done through `thread_id`:
131
+
132
+ ```python
133
+ from interpals_api import Session, Api
134
+
135
+ session = Session.login('yourusername', 'yourpassword')
136
+ api = Api(session)
137
+
138
+ uid = api.get_uid('someuser')
139
+
140
+ # Listing your chats
141
+ result = api.chat(count=9, offset=0)
142
+ print(result['chats'])
143
+
144
+ # Staring new chat (getting thread_id)
145
+ thread_id = api.get_thread_id(uid)
146
+
147
+ # Show chat messages
148
+ messages = api.chat_messages(thread_id)
149
+ print(messages)
150
+
151
+ # Send new message to the thread
152
+ api.chat_send(thread_id, "Hey! How are you?")
153
+
154
+ # Removing chat
155
+ api.chat_delete(thread_id)
156
+ ```
157
+
158
+ """
159
+
160
+ from .session import Session, SessionAsync
161
+ from .api import Api, ApiAsync