]> git.plutz.net Git - serve0/commitdiff
improve save url conversion
authorpaul <paul@plutz.net>
Sat, 29 Nov 2014 20:27:14 +0000 (20:27 +0000)
committerpaul <paul@plutz.net>
Sat, 29 Nov 2014 20:27:14 +0000 (20:27 +0000)
svn path=/trunk/; revision=25

pages/videoview.sh

index fdc19c72dbd81b99205be42ef196314b4baead04..0ec440c23d4c8d2bb4e42d0e27a7b3c6844d2913 100755 (executable)
@@ -69,6 +69,8 @@ view() {
   fi
 }
 
+alias urlsave="sed 's:%:\%25:g;s:\?:\%3F:g;s:&:\%26:g;s:'\'':\%27:g;s: :\%20:g'"
+
 _printVideo(){
   info="$1"
   cache="${_DATA}/cache/$info.cache"
@@ -90,15 +92,15 @@ _printVideo(){
     [ -r "$meta" ] || ". ${_EXEC}/helpers/genmeta.sh" "$video" "$meta"
     [ -r "$thumb" ] || ". ${_EXEC}/helpers/genthumb.sh" "$video" "$thumb"
     [ -L "$mpfake" ] || ln -s "../videos/$info" "$mpfake"
-    video="$(echo "videos/$info" |sed 's/\?/\%6F/g;s/&/\%26/g;s/'\''/%27/g')"
-    thumb="$(echo "thumbs/$info.jpg" |sed 's/\?/%6F/g')"
-    mpfake="$(echo "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:' |sed 's/\?/%6F/g')"
+    video="$(echo "videos/$info" |urlsave)"
+    thumb="$(echo "thumbs/$info.jpg" |urlsave)"
+    mpfake="$(echo "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:' |urlsave)"
 
     [ "$(($length % 60))" -lt 10 ] &&\
       minutes="$(($length / 60)):0$(($length % 60))" ||\
       minutes="$(($length / 60)):$(($length % 60))"
 
-    linkinfo="$(echo -n "$info" |sed -r 's:%:%25:g;s:\&:%26:g;')"
+    linkinfo="$(echo -n "$info" |urlsave)"
     tee "$cache" <<VIDEOend
       <li class="thumb">
         <a class="watchlink" name="$linkinfo" href="?action=watch&i=$linkinfo">