Skip to content

Commit

Permalink
Merge pull request #31 from ArthurHoaro/fix/instagram-regex
Browse files Browse the repository at this point in the history
Instagram: include query parameters in thumbnail URL
  • Loading branch information
ArthurHoaro authored Feb 22, 2021
2 parents 39bfd4f + 644d8e1 commit e77fbc8
Show file tree
Hide file tree
Showing 4 changed files with 599 additions and 452 deletions.
2 changes: 1 addition & 1 deletion src/WebThumbnailer/resources/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"hotlink_allowed": true
},
"rules": {
"image_regex": "<meta property=\"og:image\" content=\"(.*?)(?:\\?.*?)?\"",
"image_regex": "<meta property=\"og:image\" content=\"(.*?)\"",
"thumbnail_url": "${1}"
}
},
Expand Down
12 changes: 8 additions & 4 deletions tests/WebThumbnailer/Finder/QueryRegexFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ public function testQueryRegexImgurGallery()
*/
public function testQueryRegexInstagramPicture()
{
$expected = 'https://scontent-cdg2-1.cdninstagram.com/t51.2885-15/sh0.08/e35/p750x750/'
. '14719286_1129421600429160_916728922148700160_n.jpg';
$expected = 'https://scontent-cdg2-1.cdninstagram.com/v/t51.2885-15/e35/'
. '14719286_1129421600429160_916728922148700160_n.jpg'
. '?_nc_ht=scontent-cdg2-1.cdninstagram.com'
. '&_nc_cat=100&_nc_ohc=xWaFFBqAj6wAX_gqYWt&tp=1&oh=dd77c7c72429d2db9ca3666f01c60e60&oe=605B2EDA';
$allRules = DataUtils::loadJson(FileUtils::RESOURCES_PATH . 'rules.json');
$rules = $allRules['instagram']['rules'];
$options = $allRules['instagram']['options'];
Expand All @@ -295,8 +297,10 @@ public function testQueryRegexInstagramPicture()
*/
public function testQueryRegexInstagramProfile()
{
$expected = 'https://scontent-cdg2-1.cdninstagram.com/t51.2885-19/s150x150/'
. '11351823_506089142881765_717664936_a.jpg';
$expected = 'https://scontent-cdg2-1.cdninstagram.com/v/t51.2885-19/s150x150/'
. '11351823_506089142881765_717664936_a.jpg'
. '?_nc_ht=scontent-cdg2-1.cdninstagram.com'
. '&_nc_ohc=US3NCxc_VOcAX-WwNIl&tp=1&oh=2bb367a88e579c411c7c484fcc6b1e3e&oe=605C8165';
$allRules = DataUtils::loadJson(FileUtils::RESOURCES_PATH . 'rules.json');
$rules = $allRules['instagram']['rules'];
$options = $allRules['instagram']['options'];
Expand Down
Loading

0 comments on commit e77fbc8

Please sign in to comment.