From 7bb38b8397d640a2d8583820bf6c3864cf51e34c Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 2 Apr 2021 11:28:04 +0200 Subject: Adding placeholder text and image content to FB provider --- bin/get-fb-content.py | 3 ++- providers/Facebook.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/get-fb-content.py b/bin/get-fb-content.py index c7238e0..180c7b4 100644 --- a/bin/get-fb-content.py +++ b/bin/get-fb-content.py @@ -13,7 +13,8 @@ for post in get_posts(sys.argv[1], cookies=path.join(BASEDIR, '../config/faceboo posts.append({ 'id': post['post_id'], 'time': str(post['time']), - 'texts': [t.strip() for t in post['text'].split('\n') if t] + 'texts': [t.strip() for t in post['text'].split('\n') if t], + 'images': post['images'] }) print(json.dumps(posts)) diff --git a/providers/Facebook.php b/providers/Facebook.php index 7757dff..5eb588e 100644 --- a/providers/Facebook.php +++ b/providers/Facebook.php @@ -29,14 +29,24 @@ class Facebook extends \Providers\Provider { protected function _mapItems($content) { return array_map( function ($obj) { + $texts = $obj['texts']; + if (!count($texts)) { + $texts[] = ''; + } + $texts = array_merge( + $texts, + array_map(function($i) { + return sprintf('', $i); + }, $obj['images']) + ); $item = new Item(); $item->ID = $obj['id']; $item->Link = sprintf( 'https://facebook.com/%s', $obj['id'] ); - $item->Title = $obj['texts'][0]; - $item->Text = implode('
', $obj['texts']); + $item->Title = $texts[0]; + $item->Text = implode('
', $texts); $item->Time = $obj['time']; return $item; }, -- cgit v1.2.3