大佬教程收集整理的这篇文章主要介绍了Facebook 照片上传日期时间戳,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经下载了我所有的 Facebook 数据,并希望将我通过 Messenger 发送到 Google 相册的一些图片上传。我希望他们拥有正确的元数据,以便在正确的日期上传,而不是在 today
下。不幸的是,他们有 Date created
的下载日期。@H_618_7@
我尝试解析标题,但它似乎不是时间戳。@H_618_7@
我的问题是:有没有办法创建一个脚本,将正确的元数据添加到从 Facebook 下载的照片(通过 Download your information
存档)?示例标题是:142666616_209126620919024_535058535265435125_n.jpg
。此照片的日期应为 Jan 27,2021,10:53 AM
。@H_618_7@
Facebook 为您提供的存档为每个朋友提供了以下结构的文件夹:@H_618_7@
\friend_name_a1b2c3
\photos
12345678_123456788996_123124421.jpg
\gifs
\audio
messages_1.json
messages_1.json
包含您与该朋友的所有消息,以下是消息的示例:@H_618_7@
{
"sender_name": "Your Name","timestamp_ms": 1562647443588,"photos": [
{
"uri": "messages/inbox/friend_name_a1b2c3/photos/12345678_123456788996_123124421.jpg","creation_timestamp": 1562647443
}
],"type": "Generic","is_unsent": false
},
因此,使用 glob
和 utimes
我想出了以下脚本:@H_618_7@
var glob = require("glob")
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require("fs"));
var { utimes } = require("utimes");
const readJSONFiles = async () => {
const messagesFiles = glob.sync(`**/message_*.json`)
const promises = [];
messagesFiles.forEach(mFile => {
promises.push(fs.readFileAsync(mFile,'utf8'));
})
return Promise.all(promises);
}
readJSONFiles().then(result => {
const map = {};
result.forEach(data => {
const messagesContents = JSON.parse(data);
messagesContents.messages
.filter(m => m.photos)
.forEach(m => {
m.photos.filter(p => {
const splitted = p.uri.split("/")
const messagePhotoFilename = splitted[splitted.length - 1];
map[messagePhotoFilename] = m.timestamp_ms;
})
})
})
fs.writeFileSync("./map.json",JSON.Stringify(map))
}).then(() => {
fs.readFileAsync("./map.json",'utf8').then(data => {
const map = JSON.parse(data);
glob("**/*.jpg",function (er,files) {
files.forEach(file => {
const [,photo] = file.split("/");
utimes(file,{
btime: map[photo],atime: map[photo],mtime: map[photo]
});
})
})
})
});
它创建一个 file-name:date-taken
映射,然后遍历所有 .jpg
文件并更改其元数据。它的边缘确实有点粗糙,但毕竟可以完成工作。@H_618_7@
以上是大佬教程为你收集整理的Facebook 照片上传日期时间戳全部内容,希望文章能够帮你解决Facebook 照片上传日期时间戳所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。