From 09c9d015b4fc8b92dc1250cde6c9ea9b3ca541ed Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 4 Aug 2018 23:42:58 +0200 Subject: [PATCH] [ForGifsBridge] Add new bridge --- bridges/ForGifsBridge.php | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bridges/ForGifsBridge.php diff --git a/bridges/ForGifsBridge.php b/bridges/ForGifsBridge.php new file mode 100755 index 00000000..9e76017c --- /dev/null +++ b/bridges/ForGifsBridge.php @@ -0,0 +1,41 @@ +collectExpandableDatas('https://forgifs.com/gallery/srss/7'); + } + + protected function parseItem($feedItem) { + + $item = parent::parseItem($feedItem); + + $content = str_get_html($item['content']); + $img = $content->find('img', 0); + $poster = $img->src; + + // The actual gif is the same path but its id must be decremented by one. + // Example: + // http://forgifs.com/gallery/d/279419-2/Reporter-videobombed-shoulder-checks.gif + // http://forgifs.com/gallery/d/279418-2/Reporter-videobombed-shoulder-checks.gif + // Notice how this changes ----------^ + // Now let's extract that number and do some math + // Notice: Technically we could also load the content page but that would + // require unnecessary traffic. As long as it works... + $num = substr($img->src, 29, 6); + $num -= 1; + $img->src = substr_replace($img->src, $num, 29, strlen($num)); + $img->width = 'auto'; + $img->height = 'auto'; + + $item['content'] = $content; + + return $item; + + } + +}