Skip to content

Commit

Permalink
Added support for Audiomack
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jun 16, 2014
1 parent 603f574 commit df4c757
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -24,6 +24,11 @@ Media BB Codes for XenForo, imported from [s9e\TextFormatter](https://github.com
<td>Amazon Product</td>
<td>http://www.amazon.ca/gp/product/B00GQT1LNO/<br/>http://www.amazon.co.jp/gp/product/B003AKZ6I8/<br/>http://www.amazon.co.uk/gp/product/B00BET0NR6/<br/>http://www.amazon.com/dp/B002MUC0ZY<br/>http://www.amazon.com/The-BeerBelly-200-001-80-Ounce-Belly/dp/B001RB2CXY/<br/>http://www.amazon.com/gp/product/B0094H8H7I<br/>http://www.amazon.de/Netgear-WN3100RP-100PES-Repeater-integrierte-Steckdose/dp/B00ET2LTE6/<br/>http://www.amazon.fr/Vans-Authentic-Baskets-mixte-adulte/dp/B005NIKPAY/<br/>http://www.amazon.it/gp/product/B00JGOMIP6/</td>
</tr>
<tr>
<td><code>audiomack</code></td>
<td>Audiomack</td>
<td>http://www.audiomack.com/song/your-music-fix/jammin-kungs-remix-1<br/>http://www.audiomack.com/album/chance-the-rapper/acid-rap</td>
</tr>
<tr>
<td><code>bandcamp</code></td>
<td>Bandcamp</td>
Expand Down
8 changes: 6 additions & 2 deletions build/addon.xml
@@ -1,4 +1,4 @@
<addon addon_id="s9e" title="s9e Media Pack" url="https://github.com/s9e/XenForoMediaBBCodes" version_id="201406150" version_string="20140615" install_callback_class="s9e_MediaBBCodes" install_callback_method="install">
<addon addon_id="s9e" title="s9e Media Pack" url="https://github.com/s9e/XenForoMediaBBCodes" version_id="201406160" version_string="20140616" install_callback_class="s9e_MediaBBCodes" install_callback_method="install">
<bb_code_media_sites>
<site media_site_id="abcnews" site_title="ABC News" site_url="http://abcnews.go.com/" match_is_regex="1" supported="1">
<match_urls>!abcnews\.go\.com/[^/]+/video/[^/]+-(?'id'\d+)!</match_urls>
Expand All @@ -9,6 +9,10 @@
#(?'id')(?=.*?amazon\.(?&gt;c(?&gt;a|o(?&gt;m|\.(?&gt;jp|uk)))|de|fr|it)).*?amazon\.(?:co\.)?(?'tld'ca|de|fr|it|jp|uk)#</match_urls>
<embed_html><![CDATA[<!-- s9e_MediaBBCodes::renderAmazon() -->]]></embed_html>
</site>
<site media_site_id="audiomack" site_title="Audiomack" site_url="http://www.audiomack.com/" match_is_regex="1" supported="1" embed_html_callback_class="s9e_MediaBBCodes" embed_html_callback_method="embed" match_callback_class="s9e_MediaBBCodes" match_callback_method="matchAudiomack">
<match_urls>!audiomack\.com/(?'mode'album|song)/(?'id'[-\w]+/[-\w]+)!</match_urls>
<embed_html><![CDATA[<!-- s9e_MediaBBCodes::renderAudiomack() -->]]></embed_html>
</site>
<site media_site_id="bandcamp" site_title="Bandcamp" site_url="http://bandcamp.com/" match_is_regex="1" supported="1" embed_html_callback_class="s9e_MediaBBCodes" embed_html_callback_method="embed" match_callback_class="s9e_MediaBBCodes" match_callback_method="matchBandcamp">
<match_urls>!(?'id')bandcamp\.com/album/.!
!(?'id')bandcamp\.com/track/.!</match_urls>
Expand Down Expand Up @@ -242,7 +246,7 @@
<embed_html><![CDATA[<!-- s9e_MediaBBCodes::renderWsj() -->]]></embed_html>
</site>
<site media_site_id="yahooscreen" site_title="Yahoo! Screen" site_url="https://screen.yahoo.com/" match_is_regex="1" supported="1">
<match_urls>!(?=.*?screen\.yahoo\.com).*?screen\.yahoo.com/(?:[-\w]+/)?(?'id'[-\w]+)\.html!</match_urls>
<match_urls>!screen\.yahoo\.com/(?:[-\w]+/)?(?'id'[-\w]+)\.html!</match_urls>
<embed_html><![CDATA[<iframe width="640" height="360" src="https://screen.yahoo.com/{$id}.html?format=embed" allowfullscreen="" frameborder="0" scrolling="no"></iframe>]]></embed_html>
</site>
<site media_site_id="youtube" site_title="YouTube" site_url="http://www.youtube.com/" match_is_regex="1" supported="1" embed_html_callback_class="s9e_MediaBBCodes" embed_html_callback_method="embed" match_callback_class="s9e_MediaBBCodes" match_callback_method="matchYoutube">
Expand Down
17 changes: 17 additions & 0 deletions build/upload/library/s9e/MediaBBCodes.php
Expand Up @@ -270,6 +270,23 @@ public static function matchAmazon($url)
return self::match($url, $regexps, $scrapes);
}

public static function renderAudiomack($vars)
{
$vars += array('id' => null, 'mode' => null);

$html='<iframe width="100%" allowfullscreen="" frameborder="0" scrolling="no" height="';if($vars['mode']==='album')$html.='352';else$html.='144';$html.='" src="//www.audiomack.com/embed3';if($vars['mode']==='album')$html.='-album';$html.='/'.htmlspecialchars($vars['id'],2).'"></iframe>';

return $html;
}

public static function matchAudiomack($url)
{
$regexps = array('!audiomack\\.com/(?\'mode\'album|song)/(?\'id\'[-\\w]+/[-\\w]+)!');
$scrapes = array();

return self::match($url, $regexps, $scrapes);
}

public static function renderBandcamp($vars)
{
$vars += array('album_id' => null, 'track_id' => null, 'track_num' => null);
Expand Down
10 changes: 10 additions & 0 deletions tests/Test.php
Expand Up @@ -497,6 +497,16 @@ function ()
'<!-- s9e_MediaBBCodes::renderAmazon() -->',
'<iframe width="120" height="240" allowfullscreen="" frameborder="0" scrolling="no" src="//rcm.amazon.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=B002MUC0ZY&amp;o=1&amp;t=_"></iframe>'
),
array(
'id=hz-global/double-a-side-vol3;mode=album',
'<!-- s9e_MediaBBCodes::renderAudiomack() -->',
'<iframe width="100%" allowfullscreen="" frameborder="0" scrolling="no" height="352" src="//www.audiomack.com/embed3-album/hz-global/double-a-side-vol3"></iframe>'
),
array(
'id=random-2/buy-the-world-final-1;mode=song',
'<!-- s9e_MediaBBCodes::renderAudiomack() -->',
'<iframe width="100%" allowfullscreen="" frameborder="0" scrolling="no" height="144" src="//www.audiomack.com/embed3/random-2/buy-the-world-final-1"></iframe>'
),
array(
'album_id=1122163921',
'<!-- s9e_MediaBBCodes::renderBandcamp() -->',
Expand Down
8 changes: 7 additions & 1 deletion www/configure.html

Large diffs are not rendered by default.

0 comments on commit df4c757

Please sign in to comment.