Skip to content

Instantly share code, notes, and snippets.

@scorpion1201
Created July 9, 2025 09:39
Show Gist options
  • Select an option

  • Save scorpion1201/f1ae706c58ed0b67901d64721bf3c311 to your computer and use it in GitHub Desktop.

Select an option

Save scorpion1201/f1ae706c58ed0b67901d64721bf3c311 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import json
import sys
def extract_usernames(file_path, key=None):
usernames = set()
try:
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
if key:
data = data.get(key, [])
for item in data:
string_list = item.get('string_list_data', [])
if string_list:
if 'value' in string_list[0]:
usernames.add(string_list[0]['value'])
except FileNotFoundError:
print(f"오류: 파일을 찾을 수 없습니다 - {file_path}")
sys.exit(1)
except json.JSONDecodeError:
print(f"오류: {file_path} 파일의 JSON 형식이 잘못되었습니다.")
sys.exit(1)
except Exception as e:
print(f"파일 처리 중 오류 발생: {e}")
sys.exit(1)
return usernames
if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} following.json followers_1.json")
sys.exit(1)
brand_accounts_to_exclude = {
# 비교 대상에서 제외할 브랜드 계정
}
following_file = sys.argv[1]
followers_file = sys.argv[2]
following_set = extract_usernames(following_file, 'relationships_following')
followers_set = extract_usernames(followers_file)
not_following_back = following_set - followers_set
final_unfollowers = not_following_back - brand_accounts_to_exclude
print("-" * 30)
print(f"팔로잉 수: {len(following_set)}명")
print(f"팔로워 수: {len(followers_set)}명")
print("-" * 30)
if final_unfollowers:
print(f"맞팔하지 않는 사용자 ({len(final_unfollowers)}명):")
for user in sorted(list(final_unfollowers)):
print(user)
else:
print("모든 사람이 맞팔로우하고 있습니다.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment