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