Skip to content

Commit

Permalink
Add alternative audio urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram committed Jul 15, 2019
1 parent f05049f commit 40147bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Quran/Api/AyatResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Quran\Entity\Ayat;
use Quran\Entity\Edition;
use Quran\Helper\Meta;
use Quran\Helper\Request as RequestHelper;

/**
Expand Down Expand Up @@ -33,6 +34,8 @@ class AyatResponse extends QuranResponse
*/
private $includeSurat;

private $meta;

/**
* @var bool
*/
Expand Down Expand Up @@ -60,6 +63,8 @@ public function __construct($number = null, $edition = 'quran-simple', $all = fa
$this->protocol = 'https';
}

$this->meta = new Meta();

$this->edition = (new EditionResponse(null, null, null, null, false))->getEditionByIdentifier($edition);

if ($this->edition->getFormat() == 'audio') {
Expand Down Expand Up @@ -443,6 +448,8 @@ private function prepare($ayat)
$ax['number'] = $ayah->getNumber();
if (isset($this->audioEdition)) {
$ax['audio'] = $this->protocol . '://cdn.alquran.cloud/media/audio/ayah/' . $this->audioEdition->getIdentifier() . '/' . $ayah->getNumber();
$ax['audioAlternative1'] = $this->protocol . '://cdn.islamic.network/quran/media/audio/ayah/' . $this->audioEdition->getIdentifier() . '/' . $ayah->getNumber();
$ax['audioAlternative2'] = $this->protocol . '://' . $this->meta->getAudioUrlsByReciter($this->audioEdition->getIdentifier()) . $ayah->getNumber() . '.mp3';
}
$ax['text'] = $ayah->getText();
if ($this->includeEdition) {
Expand Down Expand Up @@ -477,6 +484,8 @@ private function prepare($ayat)
$a['number'] = $ayat->getNumber();
if (isset($this->audioEdition)) {
$a['audio'] = $this->protocol . '://cdn.alquran.cloud/media/audio/ayah/' . $this->audioEdition->getIdentifier() . '/' . $ayat->getNumber();
$a['audioAlternative1'] = $this->protocol . '://cdn.islamic.network/quran/media/audio/ayah/' . $this->audioEdition->getIdentifier() . '/' . $ayah->getNumber();
$a['audioAlternative2'] = $this->protocol . '://' . $this->meta->getAudioUrlsByReciter($this->audioEdition->getIdentifier()) . $ayah->getNumber() . '.mp3';
}
$a['text'] = $ayat->getText();
$a['edition'] = (new EditionResponse($ayat->getEdition()->getIdentifier()))->getResponse();
Expand Down
2 changes: 1 addition & 1 deletion src/Quran/Helper/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Meta
{
const DO_CDN_BASE_URL = 'http://islam.cdn.damascus.network/';
const DO_CDN_BASE_URL = 'islam.cdn.damascus.network/';
private $hizb_quarter;
private $page;
private $ruku;
Expand Down

0 comments on commit 40147bb

Please sign in to comment.