Forked from valeriocos/groups.io subscriptions for your email and pwd
Created
June 20, 2025 11:18
-
-
Save rpsene/14e8075244b27379f9d125af52ea82dc to your computer and use it in GitHub Desktop.
List groups.io subscriptions for a given email and pwd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# Copyright (C) 2015-2020 Bitergia | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA. | |
# | |
# Authors: | |
# Valerio Cosentino <[email protected]> | |
# Abhishek Singh <[email protected]> | |
# | |
import requests | |
GROUPSIO_API_URL = 'https://groups.io/api/v1/' | |
LOGIN = 'login' | |
GET = 'get' | |
POST = 'post' | |
GET_SUBSCRIPTIONS = 'getsubs' | |
GET_PERMISSIONS = 'getperms' | |
PER_PAGE = 100 | |
session = requests.Session() | |
def urijoin(*args): | |
"""Joins given arguments into a URI. | |
:returns: a URI string | |
""" | |
return '/'.join(map(lambda x: str(x).strip('/'), args)) | |
def fetch(url, payload, method=GET): | |
"""Fetch requests from groupsio API""" | |
if method == POST: | |
r = session.post(url, data=payload) | |
else: | |
r = session.get(url, params=payload) | |
try: | |
r.raise_for_status() | |
except requests.exceptions.HTTPError as e: | |
raise e | |
return r | |
def get_download_permission(group, login=False, email='xxxx', password='xxx'): | |
if login: | |
payload = { | |
'email': email, | |
'password': password | |
} | |
url = urijoin(GROUPSIO_API_URL, LOGIN) | |
fetch(url, payload, method=POST) | |
url = urijoin(GROUPSIO_API_URL, GET_PERMISSIONS) | |
keep_fetching = True | |
payload = { | |
"group_name": group, | |
} | |
r = fetch(url, payload) | |
response_raw = r.json() | |
return response_raw['download_archives'] | |
def get_subscriptions(email, password): | |
payload = { | |
'email': email, | |
'password': password | |
} | |
url = urijoin(GROUPSIO_API_URL, LOGIN) | |
fetch(url, payload, method=POST) | |
url = urijoin(GROUPSIO_API_URL, GET_SUBSCRIPTIONS) | |
keep_fetching = True | |
payload = { | |
"limit": PER_PAGE | |
} | |
while keep_fetching: | |
r = fetch(url, payload) | |
response_raw = r.json() | |
subscriptions = response_raw['data'] | |
for sub in subscriptions: | |
print(sub['group_name'] + ' , download archives: ' + str(get_download_permission(group=sub['group_name']))) | |
payload['page_token'] = response_raw['next_page_token'] | |
keep_fetching = response_raw['has_more'] | |
def main(): | |
groups_io_email = input('Enter your email: ') | |
groups_io_password = input('Enter your password: ') | |
print("***** ***** ***** *****") | |
get_subscriptions(groups_io_email, groups_io_password) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment