twitter-archive-to-wp
twitter-archive-to-wp copied to clipboard
Rework of media importing to handle multiple images + video
Resolves #17
This is a fairly major refactor of media handling. It enables:
- Import of mulitple media items for each tweet
- Import of video media
- Import of animated GIFs (Twitter converted these to mp4s!)
It saves multiple media items using meta keys:
-
_tweet_media_x
-
_tweet_media_type_x
All media are added to the Tweet using img
or video
tags.
I've tried to keep to the filtering conventions you have used.
It attempts some optimisation by only updating the post once when processing media for a post, and by changing how files are looped through. Specifically:
- I now load the media file list on initialization
- I index the media file list by the Tweet ID
- I use the index to only loop through the media files for the current Tweet
I did not implement a --import-media
flag - this can be done another time.
I bumped the version number and updated the readme.txt
This now VERY NEARLY successfully processes my entire Tweet history and media. There is one media not found error. I've not investigated this yet.
Success: Import Complete!
Success: 61439 tweets processed
Success: 7303 tweets skipped
Success: 2821 media found
Success: 1 media not found
Success: 0 media had an unknown type
I'll leave this with you for review. I shall attempt to provide a minimal subset of my import for testing purposes, if that's helpful? But it's too late to do that today.
Thanks! Hope you like the improvements!
Actually... hold off on this. I want to add alt text to images if I can!
Shouldn't take long.
Actually - looks like alt text isn't in the export. So don't wait for that. I'll still try and make you a test import though.
OK, here's a folder of test material. This includes:
- A multi-image tweet
- A tweet with an animated GIF
- A tweet with a video
It does not include a tweet with multiple videos, but there's no reason I can see that that wouldn't work as well.
To test this you can just unzip this into the usual location in uploads/twitter-archive
and run the importer.
@shawnhooper any thoughts on merging in this?
@timnolte I sure do! I just haven't had time to test it. I'll try to merge it this week.