InstagramFollowerAnalysis 0.2.0__py3-none-any.whl
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.
- igfollowchecker/__init__.py +4 -0
- igfollowchecker/__main__.py +2 -0
- igfollowchecker/cli.py +65 -0
- igfollowchecker/core.py +76 -0
- igfollowchecker/live.py +126 -0
- instagramfolloweranalysis-0.2.0.dist-info/METADATA +168 -0
- instagramfolloweranalysis-0.2.0.dist-info/RECORD +11 -0
- instagramfolloweranalysis-0.2.0.dist-info/WHEEL +5 -0
- instagramfolloweranalysis-0.2.0.dist-info/entry_points.txt +2 -0
- instagramfolloweranalysis-0.2.0.dist-info/licenses/LICENSE +21 -0
- instagramfolloweranalysis-0.2.0.dist-info/top_level.txt +1 -0
igfollowchecker/cli.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from . import __version__
|
|
6
|
+
from .core import analyze, compare_snapshots, load_users
|
|
7
|
+
from .live import CollectionError
|
|
8
|
+
|
|
9
|
+
def main(argv=None):
|
|
10
|
+
parser = argparse.ArgumentParser(description="Local follower analysis and optional live collection")
|
|
11
|
+
parser.add_argument("--version", action="version", version=__version__)
|
|
12
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
13
|
+
a = sub.add_parser("analyze")
|
|
14
|
+
a.add_argument("--followers", required=True)
|
|
15
|
+
a.add_argument("--following", required=True)
|
|
16
|
+
d = sub.add_parser("diff")
|
|
17
|
+
d.add_argument("--before", required=True)
|
|
18
|
+
d.add_argument("--after", required=True)
|
|
19
|
+
for p in (a, d):
|
|
20
|
+
p.add_argument("--json", action="store_true")
|
|
21
|
+
p.add_argument("--output")
|
|
22
|
+
c = sub.add_parser("collect", help="Visible Chrome, manual login/list selection")
|
|
23
|
+
c.add_argument("--username", required=True)
|
|
24
|
+
c.add_argument("--output-dir", required=True)
|
|
25
|
+
c.add_argument("--max-scrolls", type=int, default=200)
|
|
26
|
+
c.add_argument("--pause", type=float, default=1.5)
|
|
27
|
+
c.add_argument("--expected-followers", type=int)
|
|
28
|
+
c.add_argument("--expected-following", type=int)
|
|
29
|
+
args = parser.parse_args(argv)
|
|
30
|
+
try:
|
|
31
|
+
if args.command == "collect":
|
|
32
|
+
from .live import collect_live
|
|
33
|
+
result = collect_live(args.username, args.output_dir, max_scrolls=args.max_scrolls,
|
|
34
|
+
pause=args.pause, expected_followers=args.expected_followers,
|
|
35
|
+
expected_following=args.expected_following)
|
|
36
|
+
print(json.dumps(result, indent=2))
|
|
37
|
+
print("Review private files and metadata before analysis. Completeness is unverified.")
|
|
38
|
+
return 0
|
|
39
|
+
result = (analyze(load_users(args.followers), load_users(args.following)) if args.command == "analyze"
|
|
40
|
+
else compare_snapshots(load_users(args.before), load_users(args.after)))
|
|
41
|
+
encoded = json.dumps(result, ensure_ascii=False, indent=2)
|
|
42
|
+
if args.output:
|
|
43
|
+
with Path(args.output).open("x", encoding="utf-8") as stream:
|
|
44
|
+
stream.write(encoded + "\n")
|
|
45
|
+
if args.json:
|
|
46
|
+
print(encoded)
|
|
47
|
+
else:
|
|
48
|
+
for key, value in result.items():
|
|
49
|
+
if isinstance(value, dict):
|
|
50
|
+
print("Counts: " + ", ".join(f"{k}={v}" for k, v in value.items()))
|
|
51
|
+
elif isinstance(value, list):
|
|
52
|
+
print(f"{key} ({len(value)}): " + (", ".join(value) or "(none)"))
|
|
53
|
+
else:
|
|
54
|
+
print(f"{key}: {value}")
|
|
55
|
+
return 0
|
|
56
|
+
except KeyboardInterrupt:
|
|
57
|
+
print("Cancelled. Inspect output for partial files if saving was interrupted.", file=sys.stderr)
|
|
58
|
+
return 130
|
|
59
|
+
except (OSError, ValueError, UnicodeError, CollectionError) as exc:
|
|
60
|
+
print(f"igfollowchecker: {exc}", file=sys.stderr)
|
|
61
|
+
return 2
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
raise SystemExit(main())
|
igfollowchecker/core.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
import json
|
|
3
|
+
import re
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
_PATTERN = re.compile(r"[a-z0-9._]{1,30}\Z", re.ASCII)
|
|
6
|
+
|
|
7
|
+
def normalize_username(value):
|
|
8
|
+
if not isinstance(value, str):
|
|
9
|
+
raise ValueError("Username must be a string")
|
|
10
|
+
value = value.strip().removeprefix("@").lower()
|
|
11
|
+
if not _PATTERN.fullmatch(value):
|
|
12
|
+
raise ValueError("Invalid username syntax")
|
|
13
|
+
return value
|
|
14
|
+
|
|
15
|
+
def _users(values):
|
|
16
|
+
if isinstance(values, (str, bytes, dict)):
|
|
17
|
+
raise ValueError("Expected an iterable of username strings")
|
|
18
|
+
try:
|
|
19
|
+
return {normalize_username(value) for value in values}
|
|
20
|
+
except TypeError as exc:
|
|
21
|
+
raise ValueError("Expected an iterable of username strings") from exc
|
|
22
|
+
|
|
23
|
+
def _json_values(data):
|
|
24
|
+
if isinstance(data, dict):
|
|
25
|
+
keys = [k for k in ("usernames", "relationships_following", "relationships_followers") if k in data]
|
|
26
|
+
if len(keys) != 1:
|
|
27
|
+
raise ValueError("JSON object must have exactly one supported list key")
|
|
28
|
+
data = data[keys[0]]
|
|
29
|
+
if not isinstance(data, list):
|
|
30
|
+
raise ValueError("Expected a JSON list")
|
|
31
|
+
if all(isinstance(item, str) for item in data):
|
|
32
|
+
return data
|
|
33
|
+
result = []
|
|
34
|
+
for item in data:
|
|
35
|
+
if not isinstance(item, dict) or not isinstance(item.get("string_list_data"), list) or not item["string_list_data"]:
|
|
36
|
+
raise ValueError("Expected non-empty string_list_data objects; mixed formats are not supported")
|
|
37
|
+
for record in item["string_list_data"]:
|
|
38
|
+
if not isinstance(record, dict) or not isinstance(record.get("value"), str):
|
|
39
|
+
raise ValueError("Expected a string value in string_list_data")
|
|
40
|
+
result.append(record["value"])
|
|
41
|
+
return result
|
|
42
|
+
|
|
43
|
+
def load_users(path):
|
|
44
|
+
path = Path(path)
|
|
45
|
+
with path.open(encoding="utf-8-sig", newline="") as stream:
|
|
46
|
+
if path.suffix.lower() == ".json":
|
|
47
|
+
values = _json_values(json.load(stream))
|
|
48
|
+
elif path.suffix.lower() == ".txt":
|
|
49
|
+
values = [line.strip() for line in stream if line.strip()]
|
|
50
|
+
elif path.suffix.lower() == ".csv":
|
|
51
|
+
try:
|
|
52
|
+
reader = csv.reader(stream, strict=True)
|
|
53
|
+
header = next(reader, None)
|
|
54
|
+
if not header or header.count("username") != 1 or len(set(header)) != len(header):
|
|
55
|
+
raise ValueError("CSV requires unique headers including 'username'")
|
|
56
|
+
column, values = header.index("username"), []
|
|
57
|
+
for row in reader:
|
|
58
|
+
if len(row) != len(header):
|
|
59
|
+
raise ValueError(f"Wrong cell count near CSV line {reader.line_num}")
|
|
60
|
+
values.append(row[column])
|
|
61
|
+
except csv.Error as exc:
|
|
62
|
+
raise ValueError("Malformed CSV") from exc
|
|
63
|
+
else:
|
|
64
|
+
raise ValueError("Supported extensions: .json, .csv, .txt")
|
|
65
|
+
return _users(values)
|
|
66
|
+
|
|
67
|
+
def analyze(followers, following):
|
|
68
|
+
followers, following = _users(followers), _users(following)
|
|
69
|
+
return {"counts": {"followers": len(followers), "following": len(following), "mutuals": len(followers & following)},
|
|
70
|
+
"not_following_back": sorted(following - followers),
|
|
71
|
+
"fans": sorted(followers - following), "mutuals": sorted(followers & following)}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def compare_snapshots(before, after):
|
|
75
|
+
before, after = _users(before), _users(after)
|
|
76
|
+
return {"added": sorted(after - before), "removed": sorted(before - after), "unchanged_count": len(before & after)}
|
igfollowchecker/live.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import time
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from urllib.parse import urlparse
|
|
6
|
+
from .core import normalize_username
|
|
7
|
+
|
|
8
|
+
class CollectionError(RuntimeError):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
_RESERVED = {"accounts", "explore", "reels", "reel", "p", "direct", "stories", "about", "legal", "privacy", "terms", "developer", "challenge"}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def username_from_href(href):
|
|
15
|
+
if not isinstance(href, str):
|
|
16
|
+
return None
|
|
17
|
+
try:
|
|
18
|
+
parsed = urlparse(href)
|
|
19
|
+
if parsed.scheme != "https" or parsed.hostname not in {"instagram.com", "www.instagram.com"} or parsed.username or parsed.password:
|
|
20
|
+
return None
|
|
21
|
+
parts = parsed.path.strip("/").split("/")
|
|
22
|
+
if len(parts) != 1 or parts[0].lower() in _RESERVED:
|
|
23
|
+
return None
|
|
24
|
+
return normalize_username(parts[0]) if not parts[0].startswith("@") else None
|
|
25
|
+
except ValueError:
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _dialog(driver):
|
|
30
|
+
elements = [e for e in driver.find_elements("css selector", '[role="dialog"]') if e.is_displayed()]
|
|
31
|
+
return elements[-1] if elements else False
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
_SCROLL = """
|
|
35
|
+
const d=arguments[0];
|
|
36
|
+
const nodes=[d,...d.querySelectorAll('*')].filter(e => e.clientHeight>0 &&
|
|
37
|
+
e.scrollHeight>e.clientHeight+2 && ['auto','scroll'].includes(getComputedStyle(e).overflowY));
|
|
38
|
+
if (!nodes.length) return null;
|
|
39
|
+
nodes.sort((a,b)=>b.clientHeight-a.clientHeight);
|
|
40
|
+
const e=nodes[0]; e.scrollTop+=Math.max(1,e.clientHeight*0.65);
|
|
41
|
+
return {top:e.scrollTop,height:e.scrollHeight};
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _read_dialog(driver, wait, *, max_scrolls, pause):
|
|
46
|
+
names, stable, previous, reason = set(), 0, None, "scroll_limit"
|
|
47
|
+
def harvest(dialog):
|
|
48
|
+
for anchor in dialog.find_elements("css selector", 'a[href]'):
|
|
49
|
+
name = username_from_href(anchor.get_attribute("href"))
|
|
50
|
+
if name:
|
|
51
|
+
names.add(name)
|
|
52
|
+
for _ in range(max_scrolls):
|
|
53
|
+
dialog = wait.until(_dialog)
|
|
54
|
+
harvest(dialog)
|
|
55
|
+
state = driver.execute_script(_SCROLL, dialog)
|
|
56
|
+
signature = (len(names), None) if state is None else (len(names), state["top"], state["height"])
|
|
57
|
+
stable = stable + 1 if signature == previous else 0
|
|
58
|
+
previous = signature
|
|
59
|
+
if stable >= 5:
|
|
60
|
+
reason = "no_observed_progress"
|
|
61
|
+
break
|
|
62
|
+
time.sleep(pause)
|
|
63
|
+
harvest(wait.until(_dialog))
|
|
64
|
+
if not names:
|
|
65
|
+
raise CollectionError("No profiles collected: empty list, wrong dialog, page changes or loading failure. Nothing saved.")
|
|
66
|
+
return sorted(names), reason
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def collect_live(username, output_dir, *, max_scrolls=200, pause=1.5,
|
|
70
|
+
expected_followers=None, expected_following=None, prompt=input):
|
|
71
|
+
username = normalize_username(username)
|
|
72
|
+
if not 1 <= max_scrolls <= 2000 or not 1.5 <= pause <= 60:
|
|
73
|
+
raise ValueError("max_scrolls must be 1..2000 and pause must be 1.5..60 seconds")
|
|
74
|
+
if any(c is not None and c < 0 for c in (expected_followers, expected_following)):
|
|
75
|
+
raise ValueError("Expected counts cannot be negative")
|
|
76
|
+
output = Path(output_dir)
|
|
77
|
+
if output.exists():
|
|
78
|
+
raise ValueError("Choose a NEW output directory")
|
|
79
|
+
try:
|
|
80
|
+
from selenium import webdriver
|
|
81
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
82
|
+
from selenium.common.exceptions import WebDriverException
|
|
83
|
+
except ImportError as exc:
|
|
84
|
+
raise CollectionError('Install the live extra: python -m pip install -e ".[live]"') from exc
|
|
85
|
+
driver = None
|
|
86
|
+
try:
|
|
87
|
+
driver = webdriver.Chrome()
|
|
88
|
+
driver.set_page_load_timeout(45)
|
|
89
|
+
wait = WebDriverWait(driver, 20)
|
|
90
|
+
driver.get("https://www.instagram.com/")
|
|
91
|
+
prompt("Log in yourself in Chrome and complete verification manually. Press Enter here when ready; Ctrl+C cancels: ")
|
|
92
|
+
lists, details = {}, {}
|
|
93
|
+
for kind, expected in (("followers", expected_followers), ("following", expected_following)):
|
|
94
|
+
driver.get(f"https://www.instagram.com/{username}/")
|
|
95
|
+
prompt(f"Open @{username}'s {kind} list in Chrome. Confirm the correct list, then press Enter here: ")
|
|
96
|
+
print(f"Collecting {kind}; do not interact with Chrome during collection.")
|
|
97
|
+
users, reason = _read_dialog(driver, wait, max_scrolls=max_scrolls, pause=pause)
|
|
98
|
+
if expected is not None and len(users) != expected:
|
|
99
|
+
raise CollectionError(f"{kind}: collected {len(users)}, expected {expected}. Nothing saved.")
|
|
100
|
+
lists[kind] = users
|
|
101
|
+
details[kind] = {"collected": len(users), "expected_count": expected,
|
|
102
|
+
"count_matches": None if expected is None else len(users) == expected,
|
|
103
|
+
"stop_reason": reason}
|
|
104
|
+
print(f"Collected {len(users)} {kind}; completeness unverified.")
|
|
105
|
+
if prompt("Confirm correct lists. Type SAVE to store them locally, anything else to cancel: ").strip() != "SAVE":
|
|
106
|
+
raise CollectionError("Cancelled; no data saved")
|
|
107
|
+
output.mkdir(parents=True, exist_ok=False)
|
|
108
|
+
for kind, users in lists.items():
|
|
109
|
+
with (output / f"{kind}.json").open("x", encoding="utf-8") as stream:
|
|
110
|
+
json.dump(users, stream, indent=2)
|
|
111
|
+
metadata = {"schema_version": 1, "username": username,
|
|
112
|
+
"captured_at_utc": datetime.now(timezone.utc).isoformat(),
|
|
113
|
+
"source": "visible_browser_best_effort", "completeness": "unverified",
|
|
114
|
+
"warning": "Counts and scroll stability do not prove completeness; review before analysis.", "lists": details}
|
|
115
|
+
with (output / "metadata.json").open("x", encoding="utf-8") as stream:
|
|
116
|
+
json.dump(metadata, stream, indent=2)
|
|
117
|
+
return metadata
|
|
118
|
+
except WebDriverException as exc:
|
|
119
|
+
raise CollectionError("Browser collection failed. Check Chrome, login, access and correct list selection; no bypass is attempted.") from exc
|
|
120
|
+
finally:
|
|
121
|
+
if driver is not None:
|
|
122
|
+
try:
|
|
123
|
+
driver.quit()
|
|
124
|
+
except Exception:
|
|
125
|
+
pass
|
|
126
|
+
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: InstagramFollowerAnalysis
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Offline follower analysis with optional visible-browser collection
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/ismeseraphina/InstagramSentimentAnalysis
|
|
7
|
+
Project-URL: Repository, https://github.com/ismeseraphina/InstagramSentimentAnalysis
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Provides-Extra: live
|
|
12
|
+
Requires-Dist: selenium<5,>=4.10; extra == "live"
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
## CS1302A group project
|
|
16
|
+
IGFollowChecker 0.2.0
|
|
17
|
+
|
|
18
|
+
A local-first Python package for follower-list analysis, with optional visible
|
|
19
|
+
Chrome collection. No auto follow/unfollow, stealth options or credential export.
|
|
20
|
+
AI usage: Debugging code and organising tasks only
|
|
21
|
+
|
|
22
|
+
## Motivation
|
|
23
|
+
|
|
24
|
+
Comparing follower lists manually is tedious. A live-only browser script also
|
|
25
|
+
couples data collection, authentication and analysis. This package separates
|
|
26
|
+
collection from deterministic, reusable list comparison.
|
|
27
|
+
|
|
28
|
+
## Contribution / innovation
|
|
29
|
+
|
|
30
|
+
The contribution is a focused workflow: normalized inputs, explicit file formats,
|
|
31
|
+
deterministic reports, snapshot comparisons and an optional browser collector
|
|
32
|
+
whose completeness limitations are explicit. Set difference is standard, not a
|
|
33
|
+
new algorithm. We do not claim this is the first follower comparison tool.
|
|
34
|
+
|
|
35
|
+
## Install from this complete project
|
|
36
|
+
|
|
37
|
+
Python 3.9+. In the folder containing pyproject.toml:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
python3 -m venv .venv
|
|
41
|
+
source .venv/bin/activate
|
|
42
|
+
python -m pip install -e .
|
|
43
|
+
python -m unittest discover -s tests -v
|
|
44
|
+
python examples/demo.py
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Windows: use `.venv\Scripts\activate`. For live functionality install:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
python -m pip install -e ".[live]"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This installs Selenium as an optional dependency. Chrome and a graphical desktop
|
|
54
|
+
are needed. Selenium Manager handles driver discovery/setup and may download
|
|
55
|
+
components. Do not assume hosted JupyterHub can display a live browser.
|
|
56
|
+
Offline functions have no runtime third-party dependencies.
|
|
57
|
+
|
|
58
|
+
After an actual release, install the CONFIRMED distribution name from PyPI;
|
|
59
|
+
no existing publication is claimed in this document.
|
|
60
|
+
|
|
61
|
+
## Offline CLI
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
igfollowchecker analyze --followers examples/followers.json --following examples/following.json
|
|
65
|
+
igfollowchecker diff --before examples/followers.json --after examples/followers_after.json
|
|
66
|
+
igfollowchecker analyze --followers examples/followers.csv --following examples/following.json --json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Expected analysis: 3 followers, 3 following, 2 mutuals; Charlie does not follow
|
|
70
|
+
back in the synthetic dataset; Dora is a fan; Alice and Bob are mutuals.
|
|
71
|
+
Add `--output report.json` to create JSON output. Existing files are not overwritten;
|
|
72
|
+
the parent directory must already exist. Exit codes: 0 success (including detected
|
|
73
|
+
differences), 2 error, 130 interrupted command. `python -m igfollowchecker` and
|
|
74
|
+
`python main.py` accept the same command arguments.
|
|
75
|
+
|
|
76
|
+
## Live CLI
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
igfollowchecker collect --username YOUR_ACCOUNT --output-dir private_data/session-01 --max-scrolls 30
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Use only authorized data and comply with platform rules. Log in yourself in
|
|
83
|
+
Chrome, complete verification manually, and return to Terminal. For each list,
|
|
84
|
+
YOU open the correct followers/following dialog, confirm it, and press Enter.
|
|
85
|
+
Do not interact during collection. Type SAVE at the final prompt to save.
|
|
86
|
+
30 scrolls is a short smoke test, not a complete-list guarantee.
|
|
87
|
+
|
|
88
|
+
Output: followers.json, following.json, metadata.json in a NEW directory.
|
|
89
|
+
No passwords, cookies or session IDs are extracted/saved by this program. The
|
|
90
|
+
browser handles authentication normally; the program does not bypass challenges.
|
|
91
|
+
|
|
92
|
+
All captures have `completeness: unverified`. Visible profile links can be
|
|
93
|
+
incomplete or unexpected; a stable scroll is not proof of completeness. You
|
|
94
|
+
must confirm the correct dialog; this cannot be automatically guaranteed.
|
|
95
|
+
Zero collected links raises an error even for a genuinely empty list. Optional
|
|
96
|
+
`--expected-followers N --expected-following M` rejects count mismatches before
|
|
97
|
+
saving; equal counts still do not prove accuracy. Default pause 1.5 seconds,
|
|
98
|
+
maximum 200 scroll steps per list. Bounded collection does not guarantee freedom
|
|
99
|
+
from rate limits/account restrictions. Stop if access is blocked.
|
|
100
|
+
|
|
101
|
+
After reviewing files/metadata:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
igfollowchecker analyze --followers private_data/session-01/followers.json --following private_data/session-01/following.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The analyzer reads the supplied lists, NOT the sidecar metadata. Conclusions are
|
|
108
|
+
conditional on data accuracy. An interruption while saving may leave partial
|
|
109
|
+
files; metadata.json is written last. Offline does not mean encrypted.
|
|
110
|
+
|
|
111
|
+
## Python API
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from igfollowchecker import load_users, analyze, compare_snapshots
|
|
115
|
+
followers = load_users("examples/followers.json")
|
|
116
|
+
following = load_users("examples/following.json")
|
|
117
|
+
print(analyze(followers, following))
|
|
118
|
+
print(compare_snapshots(followers, {"alice", "dora", "erin"}))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`normalize_username` strips surrounding whitespace, removes one leading @,
|
|
122
|
+
lowercases and checks 1-30 ASCII letters/digits/dots/underscores. This is syntax
|
|
123
|
+
validation, not proof of an account's existence. Duplicates collapse.
|
|
124
|
+
`load_users` returns a set; malformed input raises ValueError; file/encoding
|
|
125
|
+
errors propagate. `analyze` and `compare_snapshots` accept iterables of strings
|
|
126
|
+
(not a single string) and return JSON-serializable dictionaries, with sorted lists.
|
|
127
|
+
|
|
128
|
+
## Supported input formats
|
|
129
|
+
|
|
130
|
+
- JSON string list: `["alice", "bob"]`.
|
|
131
|
+
- JSON object: `{"usernames": ["alice", "bob"]}`.
|
|
132
|
+
- JSON object list with non-empty `string_list_data` containing string `value`
|
|
133
|
+
fields, optionally wrapped in `relationships_following` or
|
|
134
|
+
`relationships_followers`. Exactly one supported wrapper key is allowed.
|
|
135
|
+
- CSV: unique headers including case-sensitive `username`; extra columns allowed.
|
|
136
|
+
Ragged records and blank usernames fail.
|
|
137
|
+
- TXT: one username per line; blank lines ignored.
|
|
138
|
+
|
|
139
|
+
Files use UTF-8 with optional BOM. See examples/export_shape.json (synthetic).
|
|
140
|
+
These are documented schemas, NOT a guarantee of compatibility with all/current
|
|
141
|
+
Instagram exports. HTML, ZIP and automatic discovery/merging of split export
|
|
142
|
+
files are unsupported. Test real authorized samples privately before claiming
|
|
143
|
+
support for their format.
|
|
144
|
+
|
|
145
|
+
## Use cases and limitations
|
|
146
|
+
|
|
147
|
+
Analyze local account lists, compare dated snapshots, or teach set operations
|
|
148
|
+
with fictional social data. `not_following_back = following - followers`,
|
|
149
|
+
`fans = followers - following`, and `mutuals = intersection`.
|
|
150
|
+
|
|
151
|
+
A removed username only means absence in the later dataset, NOT proof of an
|
|
152
|
+
unfollow. Renames, account changes, timing and incomplete inputs matter. Compare
|
|
153
|
+
same-kind lists from the same account. No automatic repair, live account
|
|
154
|
+
verification, access-control bypass or encrypted storage is provided. Memory
|
|
155
|
+
grows with input size. Typical set operations are linear under ordinary hashing
|
|
156
|
+
assumptions; sorting output adds O(k log k).
|
|
157
|
+
|
|
158
|
+
## Validation, teamwork and release
|
|
159
|
+
|
|
160
|
+
See TEST_RESULTS.txt for executed checks and untested parts. Real Instagram
|
|
161
|
+
login/collection was NOT tested here. A manual GitHub Actions workflow publishes to PyPI via Trusted Publishing.
|
|
162
|
+
See CONTRIBUTING.md, docs/DEMO.md and docs/QA.md.
|
|
163
|
+
Follow course AI disclosure rules and report actual team contributions honestly.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT for this supplied implementation; confirm ownership/permissions for any
|
|
168
|
+
existing material retained when integrating into a team repository.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
igfollowchecker/__init__.py,sha256=1fYM2jPLapU_0M_LfVrSsLppnkQ59XpJMzwYIUKiIjw,267
|
|
2
|
+
igfollowchecker/__main__.py,sha256=ee5vE0xcUZM3fPmxicvcw-IJXkm6nOwxARREHBWpF8Q,47
|
|
3
|
+
igfollowchecker/cli.py,sha256=jeSBSj2HC7WUakunPsLodXmrDbUy21Aw_m982u8Ronk,2971
|
|
4
|
+
igfollowchecker/core.py,sha256=hKxjgC7uAXK8kZodniGp5zFtCpUzMBbGuVGxN_fmWPI,3474
|
|
5
|
+
igfollowchecker/live.py,sha256=p74pVhtV-YCP8RbcS_tnRAAV_ovRiOiP3TpskdlaLJ4,6012
|
|
6
|
+
instagramfolloweranalysis-0.2.0.dist-info/licenses/LICENSE,sha256=xib3hgKV9visHvvUEtdZeAImCARD_fezoywYBE_u2Ho,1085
|
|
7
|
+
instagramfolloweranalysis-0.2.0.dist-info/METADATA,sha256=2-GbFyNTu-i15fh-nMHan6abVjrWp6qs0uQRj9hmSmA,7456
|
|
8
|
+
instagramfolloweranalysis-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
instagramfolloweranalysis-0.2.0.dist-info/entry_points.txt,sha256=WxDD0bnZsN9O3ZqFCiVnG2tP6Ykd6XFRKyJvBFeBXdQ,61
|
|
10
|
+
instagramfolloweranalysis-0.2.0.dist-info/top_level.txt,sha256=M7WQ1Q5MslAT_UNrHkzRjoC0mS05pYSpI2rihwp_l6w,16
|
|
11
|
+
instagramfolloweranalysis-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 IGFollowChecker contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
igfollowchecker
|