Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ageinfo workaround #66

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_create_zip(zip_contents_path):
"saved-search.js",
"following.js",
"follower.js",
"ageinfo.js",
} == {f.filename for f in zf.filelist}


Expand Down Expand Up @@ -77,6 +78,7 @@ def assert_imported_db(db):
"archive_account",
"archive_app",
"archive_following",
"archive_ageinfo",
} == set(db.table_names())

assert [{"accountId": "73747798"}, {"accountId": "386025404"}] == list(
Expand Down
4 changes: 4 additions & 0 deletions tests/zip_contents/ageinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
window.YTD.ageinfo.part0 =
{
"ageMeta" : { }
}
4 changes: 4 additions & 0 deletions twitter_to_sqlite/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def ad_online_conversions_unattributed(item):

@register_each("ageinfo")
def ageinfo(item):
# Prevent newer archive formats and/or empty ageinfo files from crashing
if isinstance(item, (str)) or "ageInfo" not in item["ageMeta"]:
return {'ageInfo': ''}

return item["ageMeta"]["ageInfo"]


Expand Down