mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-10 19:05:41 +01:00
Add youtube embeds to FB import
This commit is contained in:
parent
0b509aa3a5
commit
2128658e67
2 changed files with 10 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
rtv2nwevsrb7jskkoi2niza6qq
|
rtv2nwevsrb7jskkoi2niza6qq
|
||||||
tuoyt24xgoknswodnhizqehx2u
|
tuoyt24xgoknswodnhizqehx2u
|
||||||
lsdjotoggybiqsetlzmwcpptay
|
lsdjotoggybiqsetlzmwcpptay
|
||||||
|
b3atqewyj3xseyeu2tmyogss4e
|
|
@ -34,6 +34,8 @@ func makePostPath(postType string, postDate time.Time, postHash string) string {
|
||||||
return path.Join("content", postType+"s", "facebook", postDate.Format("2006-01"), postHash)
|
return path.Join("content", postType+"s", "facebook", postDate.Format("2006-01"), postHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var youtubeRE = regexp.MustCompile(`youtu(?:\.be/|be.com/watch\?v=)(.+)`)
|
||||||
|
|
||||||
func postize(e PostCheckinPhotoOrVideo, matches []string) (shared.Post, shared.MediaMap, bool, error) {
|
func postize(e PostCheckinPhotoOrVideo, matches []string) (shared.Post, shared.MediaMap, bool, error) {
|
||||||
archiveRoot := matches[1]
|
archiveRoot := matches[1]
|
||||||
|
|
||||||
|
@ -57,6 +59,11 @@ func postize(e PostCheckinPhotoOrVideo, matches []string) (shared.Post, shared.M
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore my posts on others' walls
|
||||||
|
if strings.HasPrefix(post.FrontMatter.Title, "JP Hastings-Spital wrote on") {
|
||||||
|
return post, nil, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, attach := range e.Attachments {
|
for _, attach := range e.Attachments {
|
||||||
linkURLs := attach.Data.GetSubstrings("external_context", "url")
|
linkURLs := attach.Data.GetSubstrings("external_context", "url")
|
||||||
for _, link := range linkURLs {
|
for _, link := range linkURLs {
|
||||||
|
@ -111,9 +118,8 @@ func postize(e PostCheckinPhotoOrVideo, matches []string) (shared.Post, shared.M
|
||||||
|
|
||||||
post.PostFile = postFile
|
post.PostFile = postFile
|
||||||
|
|
||||||
// Ignore my posts on others' walls
|
if match := youtubeRE.FindStringSubmatch(post.FrontMatter.BookmarkOf); len(match) > 1 {
|
||||||
if strings.HasPrefix(post.FrontMatter.Title, "JP Hastings-Spital wrote on") {
|
post.PostFile = fmt.Sprintf("%s\n\n{{< youtube \"%s\" >}}", post.PostFile, match[1])
|
||||||
return post, nil, true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return post, mm, false, nil
|
return post, mm, false, nil
|
||||||
|
|
Loading…
Reference in a new issue