remove facebook ids

This commit is contained in:
Joel Collins
2017-02-28 10:59:49 -05:00
parent 4b8142b98a
commit 1326e4cc41
4 changed files with 3 additions and 460 deletions

View File

@@ -212,7 +212,6 @@ Each record has two sections: `id` and `social`. The `id` section identifies the
* instagram: The current official Instagram handle of the legislator.
* instagram_id: The numeric ID of the current official Instagram handle of the legislator.
* facebook: The username of the current official Facebook presence of the legislator.
* facebook_id: The numeric ID of the current official Facebook presence of the legislator.
Several legislators do not have an assigned YouTube username. In these cases, only the youtube_id field is populated.
@@ -222,7 +221,7 @@ All values can be turned into URLs by preceding them with the domain name of the
* `https://youtube.com/user/[youtube]`
* `https://youtube.com/channel/[youtube_id]`
* `https://instagram/[instagram]`
* `https://facebook.com/[facebook or facebook_id]`
* `https://facebook.com/[facebook]`
Legislators are only present when they have one or more social media accounts known. Fields are omitted when the account is unknown.

File diff suppressed because it is too large Load Diff

View File

@@ -51,7 +51,6 @@ def run():
social_media_fields = [
("twitter", "twitter"),
("facebook", "facebook"),
("facebook_id", "facebook_id"),
("youtube", "youtube"),
("youtube_id", "youtube_id")
]
@@ -129,4 +128,4 @@ def run():
csv_output.writerow(legislator_row)
if __name__ == '__main__':
run()
run()

View File

@@ -14,9 +14,6 @@
# run with --verify:
# verifies that current usernames are still valid. (tries to catch renames)
#
# run with --resolvefb:
# finds both Facebook usernames and graph IDs and updates the YAML accordingly.
#
# run with --resolveyt:
# finds both YouTube usernames and channel IDs and updates the YAML accordingly.
@@ -66,7 +63,6 @@ def main():
do_update = utils.flags().get('update', False)
do_clean = utils.flags().get('clean', False)
do_verify = utils.flags().get('verify', False)
do_resolvefb = utils.flags().get('resolvefb', False)
do_resolveyt = utils.flags().get('resolveyt', False)
do_resolveig = utils.flags().get('resolveig', False)
do_resolvetw = utils.flags().get('resolvetw', False)
@@ -76,9 +72,7 @@ def main():
cache = utils.flags().get('cache', False)
force = not cache
if do_resolvefb:
service = "facebook"
elif do_resolveyt:
if do_resolveyt:
service = "youtube"
elif do_resolveig:
service = "instagram"
@@ -120,49 +114,6 @@ def main():
for m in media:
media_bioguide[m["id"]["bioguide"]] = m
def resolvefb():
# in order to preserve the comment block at the top of the file,
# copy it over into a new RtYamlList instance. We do this because
# Python list instances can't hold other random attributes.
import rtyaml
updated_media = rtyaml.RtYamlList()
if hasattr(media, '__initial_comment_block'):
updated_media.__initial_comment_block = getattr(media, '__initial_comment_block')
for m in media:
social = m['social']
if ('facebook' in social and social['facebook']) and ('facebook_id' not in social):
graph_url = "https://graph.facebook.com/%s" % social['facebook']
if re.match('\d+', social['facebook']):
social['facebook_id'] = social['facebook']
print("Looking up graph username for %s" % social['facebook'])
fbobj = requests.get(graph_url).json()
if 'username' in fbobj:
print("\tGot graph username of %s" % fbobj['username'])
social['facebook'] = fbobj['username']
else:
print("\tUnable to get graph username")
else:
try:
print("Looking up graph ID for %s" % social['facebook'])
fbobj = requests.get(graph_url).json()
if 'id' in fbobj:
print("\tGot graph ID of %s" % fbobj['id'])
social['facebook_id'] = fbobj['id']
else:
print("\tUnable to get graph ID")
except:
print("\tUnable to get graph ID for: %s" % social['facebook'])
social['facebook_id'] = None
updated_media.append(m)
print("Saving social media...")
save_data(updated_media, "legislators-social-media.yaml")
def resolveyt():
# To avoid hitting quota limits, register for a YouTube 2.0 API key at
@@ -539,8 +490,6 @@ def main():
clean()
elif do_verify:
verify()
elif do_resolvefb:
resolvefb()
elif do_resolveyt:
resolveyt()
elif do_resolveig: