2
2
// @name Amazon Video - subtitle downloader
3
3
// @description Allows you to download subtitles from Amazon Video
4
4
// @license MIT
5
- // @version 1.7.0
5
+ // @version 1.7.1
6
6
// @namespace tithen-firion.github.io
7
7
// @include /^https:\/\/www\.amazon\.com\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
8
8
// @include /^https:\/\/www\.amazon\.de\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
@@ -70,7 +70,7 @@ s.innerHTML = 'p.download:hover { cursor:pointer }';
70
70
document . head . appendChild ( s ) ;
71
71
72
72
// XML to SRT
73
- function xmlToSrt ( xmlString ) {
73
+ function xmlToSrt ( xmlString , lang ) {
74
74
xmlString = xmlString . replace ( / < t t : b r \/ > / gi, '\n' ) ;
75
75
try {
76
76
let parser = new DOMParser ( ) ;
@@ -87,6 +87,9 @@ function xmlToSrt(xmlString) {
87
87
for ( let i = 0 , l = lines . length ; i < l ; ++ i ) {
88
88
let text = lines [ i ] . innerHTML . trim ( ) ;
89
89
if ( text != '' ) {
90
+ if ( lang . indexOf ( 'ar' ) == 0 )
91
+ text = text . replace ( / ^ (? ! \u202B | \u200F ) / gm, '\u202B' ) ;
92
+
90
93
srtLines . push ( i + 1 ) ;
91
94
srtLines . push ( lines [ i ] . getAttribute ( 'begin' ) . replace ( '.' , ',' ) + ' --> ' + lines [ i ] . getAttribute ( 'end' ) . replace ( '.' , ',' ) ) ;
92
95
srtLines . push ( text ) ;
@@ -97,12 +100,12 @@ function xmlToSrt(xmlString) {
97
100
}
98
101
99
102
// download subs and save them
100
- function downloadSubs ( url , title , downloadVars ) {
103
+ function downloadSubs ( url , title , downloadVars , lang ) {
101
104
var req = new XMLHttpRequest ( ) ;
102
105
req . open ( 'get' , url ) ;
103
106
req . onload = function ( ) {
104
107
progressBar . increment ( ) ;
105
- var srt = xmlToSrt ( req . response ) ;
108
+ var srt = xmlToSrt ( req . response , lang ) ;
106
109
if ( downloadVars ) {
107
110
downloadVars . zip . file ( title , srt ) ;
108
111
-- downloadVars . subCounter ;
@@ -169,7 +172,7 @@ function downloadInfo(url, downloadVars) {
169
172
if ( downloadVars )
170
173
++ downloadVars . subCounter ;
171
174
progressBar . incrementMax ( ) ;
172
- downloadSubs ( subInfo . url , title + lang + '.srt' , downloadVars ) ;
175
+ downloadSubs ( subInfo . url , title + lang + '.srt' , downloadVars , lang ) ;
173
176
} ) ;
174
177
if ( downloadVars )
175
178
-- downloadVars . infoCounter ;
0 commit comments