Skip to content

Commit

Permalink
MediaEmbed: added support for Amazon India
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jul 26, 2017
1 parent a58a52a commit 76c01d9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/Plugins/MediaEmbed/Sites.md
Expand Up @@ -14,7 +14,7 @@
<tr>
<td><code>amazon</code></td>
<td>Amazon Product</td>
<td>http://www.amazon.ca/gp/product/B00GQT1LNO/<br/>http://www.amazon.co.jp/gp/product/B003AKZ6I8/<br/>https://www.amazon.co.uk/dp/B00EO4NN5C/<br/>http://www.amazon.com/dp/B002MUC0ZY<br/>http://www.amazon.com/The-BeerBelly-200-001-80-Ounce-Belly/dp/B001RB2CXY/<br/>https://www.amazon.com/gp/product/B00ST0KGCU/<br/>http://www.amazon.de/Netgear-WN3100RP-100PES-Repeater-integrierte-Steckdose/dp/B00ET2LTE6/<br/>https://www.amazon.es/Microsoft-Sculpt-Ergonomic-Desktop-L5V-00011/dp/B00FO10ZK0/<br/>http://www.amazon.fr/Vans-Authentic-Baskets-mixte-adulte/dp/B005NIKPAY/<br/>https://www.amazon.it/Super-Maxi-Pot-de-Nutella/dp/B0090GJ8VM/<br/>https://www.amazon.com/dp/B0018CDWLS/</td>
<td>http://www.amazon.ca/gp/product/B00GQT1LNO/<br/>http://www.amazon.co.jp/gp/product/B003AKZ6I8/<br/>https://www.amazon.co.uk/dp/B00EO4NN5C/<br/>http://www.amazon.com/dp/B002MUC0ZY<br/>http://www.amazon.com/The-BeerBelly-200-001-80-Ounce-Belly/dp/B001RB2CXY/<br/>https://www.amazon.com/gp/product/B00ST0KGCU/<br/>http://www.amazon.de/Netgear-WN3100RP-100PES-Repeater-integrierte-Steckdose/dp/B00ET2LTE6/<br/>https://www.amazon.es/Microsoft-Sculpt-Ergonomic-Desktop-L5V-00011/dp/B00FO10ZK0/<br/>http://www.amazon.fr/Vans-Authentic-Baskets-mixte-adulte/dp/B005NIKPAY/<br/>http://www.amazon.in/Vans-Unisex-Authentic-Midnight-Sneakers/dp/B01I3LNWQG/<br/>https://www.amazon.it/Super-Maxi-Pot-de-Nutella/dp/B0090GJ8VM/<br/>https://www.amazon.com/dp/B0018CDWLS/</td>
</tr>
<tr>
<td><code>audioboom</code></td>
Expand Down
4 changes: 2 additions & 2 deletions src/Bundles/MediaPack.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Bundles/MediaPack/Renderer.php

Large diffs are not rendered by default.

Expand Up @@ -12,7 +12,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
/** {@inheritdoc} */
protected $items = [
'abcnews'=>['extract'=>'!abcnews\\.go\\.com/(?:video/embed\\?id=|[^/]+/video/[^/]+-)(?\'id\'\\d+)!','host'=>'abcnews.go.com','iframe'=>['height'=>'360','src'=>'//abcnews.go.com/video/embed?id={@id}','width'=>'640'],'name'=>'ABC News','tags'=>['news']],
'amazon'=>['extract'=>['#/(?:dp|gp/product)/(?\'id\'[A-Z0-9]+)#','#amazon\\.(?:co\\.)?(?\'tld\'ca|de|es|fr|it|jp|uk)#'],'host'=>['amazon.ca','amazon.co.uk','amazon.co.jp','amazon.com','amazon.de','amazon.es','amazon.fr','amazon.it'],'iframe'=>['height'=>'240','src'=>'//<xsl:choose><xsl:when test="@tld=\'es\'or@tld=\'it\'">rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&amp;bc1=FFFFFF&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;p=8&amp;l=as1&amp;f=ifr&amp;asins=<xsl:value-of select="@id"/>&amp;o=<xsl:choose><xsl:when test="@tld=\'es\'">30</xsl:when><xsl:otherwise>29</xsl:otherwise></xsl:choose>&amp;t=<xsl:choose><xsl:when test="@tld=\'es\'and$AMAZON_ASSOCIATE_TAG_ES"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_ES"/></xsl:when><xsl:when test="@tld=\'it\'and$AMAZON_ASSOCIATE_TAG_IT"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_IT"/></xsl:when><xsl:otherwise>_</xsl:otherwise></xsl:choose></xsl:when><xsl:otherwise>ws-<xsl:choose><xsl:when test="@tld=\'jp\'">fe</xsl:when><xsl:when test="@tld and contains(\'desfrituk\',@tld)">eu</xsl:when><xsl:otherwise>na</xsl:otherwise></xsl:choose>.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=<xsl:choose><xsl:when test="@tld"><xsl:value-of select="translate(@tld,\'acdefijkprstu\',\'ACDEFIJBPRSTG\')"/></xsl:when><xsl:otherwise>US</xsl:otherwise></xsl:choose>&amp;ad_type=product_link&amp;tracking_id=<xsl:choose><xsl:when test="@tld=\'ca\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_CA"/></xsl:when><xsl:when test="@tld=\'de\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_DE"/></xsl:when><xsl:when test="@tld=\'fr\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_FR"/></xsl:when><xsl:when test="@tld=\'jp\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_JP"/></xsl:when><xsl:when test="@tld=\'uk\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_UK"/></xsl:when><xsl:when test="$AMAZON_ASSOCIATE_TAG"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG"/></xsl:when><xsl:otherwise>-20</xsl:otherwise></xsl:choose>&amp;marketplace=amazon&amp;region=<xsl:choose><xsl:when test="@tld"><xsl:value-of select="translate(@tld,\'acdefijkprstu\',\'ACDEFIJBPRSTG\')"/></xsl:when><xsl:otherwise>US</xsl:otherwise></xsl:choose>&amp;asins=<xsl:value-of select="@id"/>&amp;show_border=true&amp;link_opens_in_new_window=true</xsl:otherwise></xsl:choose>','width'=>'120'],'name'=>'Amazon Product'],
'amazon'=>['extract'=>['#/(?:dp|gp/product)/(?\'id\'[A-Z0-9]+)#','#amazon\\.(?:co\\.)?(?\'tld\'ca|de|es|fr|in|it|jp|uk)#'],'host'=>['amazon.ca','amazon.co.uk','amazon.co.jp','amazon.com','amazon.de','amazon.es','amazon.fr','amazon.in','amazon.it'],'iframe'=>['height'=>'240','src'=>'//<xsl:choose><xsl:when test="@tld=\'es\'or@tld=\'it\'">rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&amp;bc1=FFFFFF&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;p=8&amp;l=as1&amp;f=ifr&amp;asins=<xsl:value-of select="@id"/>&amp;o=<xsl:choose><xsl:when test="@tld=\'es\'">30</xsl:when><xsl:otherwise>29</xsl:otherwise></xsl:choose>&amp;t=<xsl:choose><xsl:when test="@tld=\'es\'and$AMAZON_ASSOCIATE_TAG_ES"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_ES"/></xsl:when><xsl:when test="@tld=\'it\'and$AMAZON_ASSOCIATE_TAG_IT"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_IT"/></xsl:when><xsl:otherwise>_</xsl:otherwise></xsl:choose></xsl:when><xsl:otherwise>ws-<xsl:choose><xsl:when test="@tld=\'in\'">in</xsl:when><xsl:when test="@tld=\'jp\'">fe</xsl:when><xsl:when test="@tld and contains(\'desfrituk\',@tld)">eu</xsl:when><xsl:otherwise>na</xsl:otherwise></xsl:choose>.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=<xsl:choose><xsl:when test="@tld"><xsl:value-of select="translate(@tld,\'acdefijknprstu\',\'ACDEFIJBNPRSTG\')"/></xsl:when><xsl:otherwise>US</xsl:otherwise></xsl:choose>&amp;ad_type=product_link&amp;tracking_id=<xsl:choose><xsl:when test="@tld=\'ca\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_CA"/></xsl:when><xsl:when test="@tld=\'de\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_DE"/></xsl:when><xsl:when test="@tld=\'fr\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_FR"/></xsl:when><xsl:when test="@tld=\'in\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_IN"/></xsl:when><xsl:when test="@tld=\'jp\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_JP"/></xsl:when><xsl:when test="@tld=\'uk\'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_UK"/></xsl:when><xsl:when test="$AMAZON_ASSOCIATE_TAG"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG"/></xsl:when><xsl:otherwise>-20</xsl:otherwise></xsl:choose>&amp;marketplace=amazon&amp;region=<xsl:choose><xsl:when test="@tld"><xsl:value-of select="translate(@tld,\'acdefijknprstu\',\'ACDEFIJBNPRSTG\')"/></xsl:when><xsl:otherwise>US</xsl:otherwise></xsl:choose>&amp;asins=<xsl:value-of select="@id"/>&amp;show_border=true&amp;link_opens_in_new_window=true</xsl:otherwise></xsl:choose>','width'=>'120'],'name'=>'Amazon Product'],
'audioboom'=>['extract'=>'!audioboo(?:\\.f|m\\.co)m/(?:boo|post)s/(?\'id\'\\d+)!','host'=>['audioboo.fm','audioboom.com'],'iframe'=>['height'=>'150','max-width'=>'700','src'=>'//audioboom.com/posts/{@id}/embed/v3','width'=>'100%'],'name'=>'audioBoom','tags'=>['podcasts']],
'audiomack'=>['choose'=>['otherwise'=>['iframe'=>['height'=>'252','max-width'=>'900','src'=>'https://www.audiomack.com/embed/song/{@id}','width'=>'100%']],'when'=>['iframe'=>['height'=>'400','max-width'=>'900','src'=>'https://www.audiomack.com/embed/album/{@id}','width'=>'100%'],'test'=>'@mode=\'album\'']],'extract'=>'!audiomack\\.com/(?\'mode\'album|song)/(?\'id\'[-\\w]+/[-\\w]+)!','host'=>'audiomack.com','name'=>'Audiomack','tags'=>['music']],
'bandcamp'=>['host'=>'bandcamp.com','iframe'=>['height'=>'400','src'=>'//bandcamp.com/EmbeddedPlayer/size=large/minimal=true/<xsl:choose><xsl:when test="@album_id">album=<xsl:value-of select="@album_id"/><xsl:if test="@track_num">/t=<xsl:value-of select="@track_num"/></xsl:if></xsl:when><xsl:otherwise>track=<xsl:value-of select="@track_id"/></xsl:otherwise></xsl:choose>','width'=>'400'],'name'=>'Bandcamp','scrape'=>[['extract'=>'!/album=(?\'album_id\'\\d+)!','match'=>'!bandcamp\\.com/album/.!'],['extract'=>['!"album_id":(?\'album_id\'\\d+)!','!"track_num":(?\'track_num\'\\d+)!','!/track=(?\'track_id\'\\d+)!'],'match'=>'!bandcamp\\.com/track/.!']],'tags'=>['music']],
Expand Down
10 changes: 7 additions & 3 deletions src/Plugins/MediaEmbed/Configurator/sites/amazon.xml
Expand Up @@ -8,6 +8,7 @@
<example>http://www.amazon.de/Netgear-WN3100RP-100PES-Repeater-integrierte-Steckdose/dp/B00ET2LTE6/</example>
<example>https://www.amazon.es/Microsoft-Sculpt-Ergonomic-Desktop-L5V-00011/dp/B00FO10ZK0/</example>
<example>http://www.amazon.fr/Vans-Authentic-Baskets-mixte-adulte/dp/B005NIKPAY/</example>
<example>http://www.amazon.in/Vans-Unisex-Authentic-Midnight-Sneakers/dp/B01I3LNWQG/</example>
<example>https://www.amazon.it/Super-Maxi-Pot-de-Nutella/dp/B0090GJ8VM/</example>
<example>https://www.amazon.com/dp/B0018CDWLS/</example>

Expand All @@ -18,9 +19,10 @@
<host>amazon.de</host>
<host>amazon.es</host>
<host>amazon.fr</host>
<host>amazon.in</host>
<host>amazon.it</host>
<extract>#/(?:dp|gp/product)/(?'id'[A-Z0-9]+)#</extract>
<extract>#amazon\.(?:co\.)?(?'tld'ca|de|es|fr|it|jp|uk)#</extract>
<extract>#amazon\.(?:co\.)?(?'tld'ca|de|es|fr|in|it|jp|uk)#</extract>
<iframe width="120" height="240">
<src><![CDATA[
<xsl:text>//</xsl:text>
Expand All @@ -43,6 +45,7 @@
<xsl:otherwise>
<xsl:text>ws-</xsl:text>
<xsl:choose>
<xsl:when test="@tld='in'">in</xsl:when>
<xsl:when test="@tld='jp'">fe</xsl:when>
<xsl:when test="@tld and contains('desfrituk',@tld)">eu</xsl:when>
<xsl:otherwise>na</xsl:otherwise>
Expand All @@ -51,7 +54,7 @@
<xsl:choose>
<xsl:when test="@tld">
<!-- uk will become GB -->
<xsl:value-of select="translate(@tld,'acdefijkprstu','ACDEFIJBPRSTG')"/>
<xsl:value-of select="translate(@tld,'acdefijknprstu','ACDEFIJBNPRSTG')"/>
</xsl:when>
<xsl:otherwise>US</xsl:otherwise>
</xsl:choose>
Expand All @@ -60,6 +63,7 @@
<xsl:when test="@tld='ca'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_CA"/></xsl:when>
<xsl:when test="@tld='de'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_DE"/></xsl:when>
<xsl:when test="@tld='fr'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_FR"/></xsl:when>
<xsl:when test="@tld='in'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_IN"/></xsl:when>
<xsl:when test="@tld='jp'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_JP"/></xsl:when>
<xsl:when test="@tld='uk'"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG_UK"/></xsl:when>
<xsl:when test="$AMAZON_ASSOCIATE_TAG"><xsl:value-of select="$AMAZON_ASSOCIATE_TAG"/></xsl:when>
Expand All @@ -68,7 +72,7 @@
<xsl:text>&amp;marketplace=amazon&amp;region=</xsl:text>
<xsl:choose>
<xsl:when test="@tld">
<xsl:value-of select="translate(@tld,'acdefijkprstu','ACDEFIJBPRSTG')"/>
<xsl:value-of select="translate(@tld,'acdefijknprstu','ACDEFIJBNPRSTG')"/>
</xsl:when>
<xsl:otherwise>US</xsl:otherwise>
</xsl:choose>
Expand Down
18 changes: 18 additions & 0 deletions tests/Plugins/MediaEmbed/ParserTest.php
Expand Up @@ -1556,6 +1556,15 @@ function ($configurator)
$configurator->MediaEmbed->add('amazon');
}
],
[
'http://www.amazon.in/Vans-Unisex-Authentic-Midnight-Sneakers/dp/B01I3LNWQG/',
'<r><AMAZON id="B01I3LNWQG" tld="in" url="http://www.amazon.in/Vans-Unisex-Authentic-Midnight-Sneakers/dp/B01I3LNWQG/">http://www.amazon.in/Vans-Unisex-Authentic-Midnight-Sneakers/dp/B01I3LNWQG/</AMAZON></r>',
[],
function ($configurator)
{
$configurator->MediaEmbed->add('amazon');
}
],
[
'http://www.amazon.it/gp/product/B00JGOMIP6/',
'<r><AMAZON id="B00JGOMIP6" tld="it" url="http://www.amazon.it/gp/product/B00JGOMIP6/">http://www.amazon.it/gp/product/B00JGOMIP6/</AMAZON></r>',
Expand Down Expand Up @@ -3642,6 +3651,15 @@ function ($configurator)
$configurator->MediaEmbed->add('amazon');
}
],
[
'http://www.amazon.in/Vans-Unisex-Authentic-Midnight-Sneakers/dp/B01I3LNWQG/',
'<span data-s9e-mediaembed="amazon" style="display:inline-block;width:100%;max-width:120px"><span style="display:block;overflow:hidden;position:relative;padding-bottom:200%"><iframe allowfullscreen="" scrolling="no" style="border:0;height:100%;left:0;position:absolute;width:100%" src="//ws-in.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=IN&amp;ad_type=product_link&amp;tracking_id=&amp;marketplace=amazon&amp;region=IN&amp;asins=B01I3LNWQG&amp;show_border=true&amp;link_opens_in_new_window=true"></iframe></span></span>',
[],
function ($configurator)
{
$configurator->MediaEmbed->add('amazon');
}
],
[
'http://www.amazon.es/Vans-OLD-SKOOL-BLACK-WHITE/dp/B000R3QPEA/',
'<span data-s9e-mediaembed="amazon" style="display:inline-block;width:100%;max-width:120px"><span style="display:block;overflow:hidden;position:relative;padding-bottom:200%"><iframe allowfullscreen="" scrolling="no" style="border:0;height:100%;left:0;position:absolute;width:100%" src="//rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&amp;bc1=FFFFFF&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;p=8&amp;l=as1&amp;f=ifr&amp;asins=B000R3QPEA&amp;o=30&amp;t=es-20"></iframe></span></span>',
Expand Down

0 comments on commit 76c01d9

Please sign in to comment.