/usr/share/nanoblogger-extra/plugins/shortcode/youtube.sh is in nanoblogger-extra 3.4.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | # NanoBlogger Shortcode YouTube plugin
# e.g. [youtube=http://www.youtube.com/...] -> <object type=...
# e.g. [youtube]http://www.youtube.com/...[/youtube] -> <object type...
# e.g. [youtube width=425 height=344]http://www.youtube.com/...[/youtube] -> <object type...
# quickly detect youtube shortcode
shortcode_youtube_open="${NB_MetaBody//*[\[]youtube=*/true}"
shortcode_youtube_enclosed="${NB_MetaBody//*[\[]youtube[\]]*[\[]\/youtube*/true}"
shortcode_youtube_encwatts="${NB_MetaBody//*[\[]youtube *[\[]\/youtube*/true}"
# shortocode for url only
sc_youtube_open(){
if [ "$shortcode_youtube_open" = true ]; then
sc_lines=`echo "$NB_MetaBody" |grep -n "\[youtube\=" |sed -e '/[ ]/ s//_SHORTCODESPACER_/g'`
sc_idlist=(`for sc_line in ${sc_lines[@]}; do echo ${sc_line%%\:*}; done`)
shortcode_youtube_data=`echo "$NB_MetaBody" |sed -e '/\[youtube\=/!d; /[^ ]*.*\[youtube[\=]/ s///g; /\][^ ]*.*/ s///g'`
sc_lineid=0
for shortcode_youtube_line in ${shortcode_youtube_data[@]}; do
youtube_url=; youtubeurlmod_xargs=; shortcode_youtube_output=; shortcode_youtube_sedscript=
youtube_urlneedsmod="${shortcode_youtube_line//*watch\?v\=*/true}"
if [ "$youtube_urlneedsmod" = true ]; then
youtubeurlmod_xargs="&hl=en&fs=1"
shortcode_youtube_line="${shortcode_youtube_line//watch\?v\=/v/}"
fi
[ ! -z "$youtubeurlmod_xargs" ] && shortcode_youtube_line="${shortcode_youtube_line}$youtubeurlmod_xargs"
youtube_url=`echo "$shortcode_youtube_line" |sed -e '/\&/ s//\\\&\\\;/g; /\&\;\&\;/ s//\\\&\\\;/g'`
youtube_url=`echo "${youtube_url//\//\\\\/}\\\\"`
shortcode_youtube_output=' <object type="application\/x-shockwave-flash" data="'$youtube_url'" width="425" height="344"><param name="movie" value="'$youtube_url'" \/><param name="allowFullScreen" value="true" \/><\/object>'
sc_id="${sc_idlist[$sc_lineid]}"
shortcode_youtube_sedscript='s/[ ]\[youtube\=http\:\/\/*.*[A-Za-z0-9]\]/ '$shortcode_youtube_output' /; '$sc_id' s/[ ]\[youtube\=http\:\/\/*.*[A-Za-z0-9]\]$/ '$shortcode_youtube_output'/; '$sc_id' s/^\[youtube\=http\:\/\/*.*[A-Za-z0-9]\] /'$shortcode_youtube_output' /; '$sc_id' s/^\[youtube\=http\:\/\/*.*[A-Za-z0-9]\]$/'$shortcode_youtube_output'/'
NB_MetaBody=`echo "$NB_MetaBody" |sed -e "$shortcode_youtube_sedscript"`
let sc_lineid=${sc_lineid}+1
done
fi
}
# shortocode for url enclosed
sc_youtube_enclosed(){
if [ "$shortcode_youtube_enclosed" = true ]; then
sc_lines=`echo "$NB_MetaBody" |grep -n "\[youtube\]http\:\/\/*.*[A-Za-z0-9]\[\/youtube\]" |sed -e '/[ ]/ s//_SHORTCODESPACER_/g'`
sc_idlist=(`for sc_line in ${sc_lines[@]}; do echo ${sc_line%%\:*}; done`)
shortcode_youtube_data=`echo "$NB_MetaBody" |sed -e '/\[youtube\]http\:\/\/*.*[A-Za-z0-9]\[\/youtube\]/!d; /[^ ]*.*\[youtube\]/ s///g; /\[\/youtube\]*.*/ s///g'`
sc_lineid=0
for shortcode_youtube_line in ${shortcode_youtube_data[@]}; do
youtube_url=; youtubeurlmod_xargs=; shortcode_youtube_output=; shortcode_youtube_sedscript=
youtube_urlneedsmod="${shortcode_youtube_line//*watch\?v\=*/true}"
if [ "$youtube_urlneedsmod" = true ]; then
youtubeurlmod_xargs="&hl=en&fs=1"
shortcode_youtube_line="${shortcode_youtube_line//watch\?v\=/v/}"
fi
[ ! -z "$youtubeurlmod_xargs" ] && shortcode_youtube_line="${shortcode_youtube_line}$youtubeurlmod_xargs"
youtube_url=`echo "$shortcode_youtube_line" |sed -e '/\&/ s//\\\&\\\;/g; /\&\;\&\;/ s//\\\&\\\;/g'`
youtube_url=`echo "${youtube_url//\//\\\\/}\\\\"`
shortcode_youtube_output=' <object type="application\/x-shockwave-flash" data="'$youtube_url'" width="425" height="344"><param name="movie" value="'$youtube_url'" \/><param name="allowFullScreen" value="true" \/><\/object>'
sc_id="${sc_idlist[$sc_lineid]}"
shortcode_youtube_sedscript=''$sc_id' s/[ ]\[youtube\]http\:\/\/*.*[A-Za-z0-9]\[\/youtube\]/ '$shortcode_youtube_output' /; '$sc_id' s/[ ]\[youtube\]http\:\/\/*.*[A-Za-z0-9]\[\/youtube\]$/ '$shortcode_youtube_output'/; '$sc_id' s/^\[youtube\]http\:\/\/*.*[A-Za-z0-9]\[\/youtube\] /'$shortcode_youtube_output' /; '$sc_id' s/^\[youtube\]http\:\/\/*.*[A-Za-z0-9]\[\/youtube\]$/'$shortcode_youtube_output'/'
NB_MetaBody=`echo "$NB_MetaBody" |sed -e "$shortcode_youtube_sedscript"`
let sc_lineid=${sc_lineid}+1
done
fi
}
# shortcode for url with attributes
sc_youtube_encwatts(){
if [ "$shortcode_youtube_encwatts" = true ]; then
sc_lines=`echo "$NB_MetaBody" |grep -n "\[youtube " |sed -e '/[ ]/ s//_SHORTCODESPACER_/g'`
sc_idlist=(`for sc_line in ${sc_lines[@]}; do echo ${sc_line%%\:*}; done`)
shortcode_youtube_data=`echo "$NB_MetaBody" |sed -e '/\[youtube /!d; /[^ ].*\[youtube / s///; /\[\/youtube\]*.*/ s///; /[ ]/ s//_SHORTCODESPACER_/g'`
sc_lineid=0
for shortcode_youtube_line in ${shortcode_youtube_data[@]}; do
youtube_url=; youtubeurlmod_xargs=; shortcode_youtube_atts=; shortcode_youtube_output=; shortcode_youtube_sedscript=
shortcode_youtube_line="${shortcode_youtube_line//_SHORTCODESPACER_/ }"
youtube_url=`echo "$shortcode_youtube_line" |sed -e '/[^ ].*\]/ s///'`
youtube_urlneedsmod="${youtube_url//*watch\?v\=*/true}"
if [ "$youtube_urlneedsmod" = true ]; then
youtubeurlmod_xargs="&hl=en&fs=1"
youtube_url="${youtube_url//watch\?v\=/v/}"
fi
[ ! -z "$youtubeurlmod_xargs" ] && youtube_url="${youtube_url}$youtubeurlmod_xargs"
youtube_url=`echo "$youtube_url" |sed -e '/\&/ s//\\\&\\\;/g; /\&\;\&\;/ s//\\\&\\\;/g'`
youtube_url=`echo "${youtube_url//\//\\\\/}\\\\"`
shortcode_youtube_atts="${shortcode_youtube_line//*\[youtube[ ]}"; shortcode_youtube_atts="${shortcode_youtube_atts//\]*}"
for sc_youtube_attr in ${shortcode_youtube_atts[*]}; do
sc_youtube_attr_name="${sc_youtube_attr//\=*}"; sc_youtube_attr_val="${sc_youtube_attr//*\=}"; sc_youtube_attr_val="${sc_youtube_attr_val//\"/}"
[ "$sc_youtube_attr_name" = width ] && youtube_width="$sc_youtube_attr_val"
[ "$sc_youtube_attr_name" = height ] && youtube_height="$sc_youtube_attr_val"
done
shortcode_youtube_output=' <object type="application\/x-shockwave-flash" data="'$youtube_url'" width="'$youtube_width'" height="'$youtube_height'"><param name="movie" value="'$youtube_url'" \/><param name="allowFullScreen" value="true" \/><\/object>'
sc_id="${sc_idlist[$sc_lineid]}"
shortcode_youtube_sedscript=''$sc_id' s/[ ]\[youtube [^ ].*\][^ ].*\[\/youtube\]/ '$shortcode_youtube_output' /; '$sc_id' s/[ ]\[youtube *.*\][^ ].*\[\/youtube\]$/ '$shortcode_youtube_output'/; '$sc_id' s/^\[youtube *.*\][^ ].*\[\/youtube\] /'$shortcode_youtube_output' /; '$sc_id' s/^\[youtube *.*\][^ ].*\[\/youtube\]$/'$shortcode_youtube_output'/'
NB_MetaBody=`echo "$NB_MetaBody" |sed -e "$shortcode_youtube_sedscript"`
let sc_lineid=${sc_lineid}+1
done
fi
}
for sc_youtube in sc_youtube_open sc_youtube_enclosed sc_youtube_encwatts; do
$sc_youtube
done
|