Skip to content

Commit

Permalink
Add: Audio Description support
Browse files Browse the repository at this point in the history
  • Loading branch information
Varstahl committed Mar 5, 2019
1 parent 012d322 commit 9a0cac1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ msgctxt "#30004"
msgid "Stream Bitrate (0 - Ask)"
msgstr ""

#empty strings with id 30005
msgctxt "#30005"
msgid "Audio descriptions (disables 5.1/7.1)"
msgstr ""

msgctxt "#30006"
msgid "Store Credentials instead of using the Cookie?"
Expand Down
1 change: 1 addition & 0 deletions plugin.video.amazon-test/resources/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __getattr__(self, name):
elif 'region' == name: return int(self._gs('region'))
elif 'proxyaddress' == name: return getConfig('proxyaddress')
elif 'subtitleStretch' == name: return self._gs('sub_stretch') == 'true'
elif 'audioDescriptions' == name: return self._gs('audio_description') == 'true'


def jsonRPC(method, props='', param=None):
Expand Down
1 change: 1 addition & 0 deletions plugin.video.amazon-test/resources/lib/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def getURLData(mode, asin, retformat='json', devicetypeid='AOAGZA014O5RE', versi
url += '&resourceUsage=ImmediateConsumption&consumptionType=Streaming&deviceDrmOverride=CENC' \
'&deviceStreamingTechnologyOverride=DASH&deviceProtocolOverride=Https' \
'&deviceBitrateAdaptationsOverride=CVBR%2CCBR&audioTrackId=all'
url += '&languageFeature=MLFv2' # Audio Description tracks
url += '&videoMaterialType=' + vMT
url += '&desiredResources=' + dRes
url += '&supportedDRMKeyScheme=DUAL_KEY' if (not g.platform & g.OS_ANDROID) and ('PlaybackUrls' in dRes) else ''
Expand Down
2 changes: 1 addition & 1 deletion plugin.video.amazon-test/resources/lib/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _IStreamPlayback(asin, name, trailer, isAdult, extern):
is_version = KodiAddon(g.is_addon).getAddonInfo('version') if g.is_addon else '0'
is_binary = xbmc.getCondVisibility('System.HasAddon(kodi.binary.instance.inputstream)')

if trailer != 2:
if (not s.audioDescriptions) and (trailer != 2):
mpd = re.sub(r'(~|%7E)', '', mpd)

if drm_check and (not g.platform & g.OS_ANDROID) and (not is_binary):
Expand Down
7 changes: 5 additions & 2 deletions plugin.video.amazon-test/resources/lib/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,13 @@ def _AlterMPD(self, endpoint, headers, data):
new_sets = []
for s in re.findall(r'(<AdaptationSet\s+[^>]*>)(.*?</AdaptationSet>)', content, flags=re.DOTALL):
s = list(s)
audioTrack = re.search(r' audioTrackId="([a-z]{2})(-[a-z0-9]{2,})[^"]+[^>]+ lang="([a-z]{2})"', s[0])
audioTrack = re.search(r' audioTrackId="([a-z]{2})(-[a-z0-9]{2,})_(dialog|descriptive)[^"]+[^>]+ lang="([a-z]{2})"', s[0])
if None is not audioTrack:
audioTrack = audioTrack.groups()
s[0] = s[0].replace('lang="%s"' % audioTrack[2], 'lang="%s"' % self._AdjustLocale(audioTrack[0] + audioTrack[1], langCount[audioTrack[0]]))
newLocale = self._AdjustLocale(audioTrack[0] + audioTrack[1], langCount[audioTrack[0]])
if 'descriptive' == audioTrack[2]:
newLocale += (' ' if '-' in newLocale else '-') + '[Audio Description]'
s[0] = s[0].replace('lang="%s"' % audioTrack[3], 'lang="%s"' % newLocale)
new_sets.append(s[0] + s[1])

self._SendResponse(status_code, headers, header + ''.join(new_sets) + footer, True)
Expand Down
6 changes: 5 additions & 1 deletion plugin.video.amazon-test/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
<setting id="drm_check" type="bool" label="30020" visible="eq(-20,3)" default="true"/>
<setting id="fallback_method" type="enum" label="Fallback" values="None|Browser|Script/Batch|Android" default="0" visible="eq(-21,3)" enable="eq(-1,true)" subsetting="true"/>
</category>
<!-- Connection -->
<!-- Language -->
<category label="30021">
<!-- Audio -->
<setting label="30033" type="lsep"/>
<setting id="audio_description" type="bool" label="30005" default="false"/>
<!-- Subtitles -->
<setting label="30034" type="lsep"/>
<setting id="sub_stretch" type="bool" label="30028" default="false"/>
</category>
Expand Down

0 comments on commit 9a0cac1

Please sign in to comment.