I’m often going to TVsubtitles to download subtitles for TV shows episodes. But the original page doesn’t provide an optimized flow: for example, on the home page there are two sections called “Latest subtitles” and “Most downloaded subtitles”, but they don’t link to the subtitle files. Instead they link to intermediate nagging pages where you then can download the subtitles.
For example, today it appears like this:

Without Greasemonkey script
the Weeds 5×01 doesn’t link to the subtitle file, but links actually to an intermediate page:

Intermediate (and useless) download page
To remediate this and get direct download links, I’ve made the following Greasemonkey script:
// ==UserScript==
// @name tvsubtitles.net
// @namespace tvsubtitles.net
// @description tvsubtitles.net
// @include http://www.tvsubtitles.net/*
// ==/UserScript==
// http://www.tvsubtitles.net/subtitle-63109.html (/subtitle-) -->
// http://www.tvsubtitles.net/download-63109.html (/download-)
var allLinks, thisLink;
xpath = '//a[contains(@href, "subtitle-")]';
allLinks = document.evaluate(xpath,document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
thisLink.href = thisLink.href.replace(/subtitle-/, "download-");
if( thisLink.title != "" ) {
thisLink.firstChild.textContent = thisLink.firstChild.textContent + " (" + thisLink.title + ")";
}
}
With that script, the link to the intermediate page is replaced by a link to the subtitle file, and some information about the release corresponding to that sub file is also added:

Using my Greasemonkey script
UPDATE: I’ve just seen that there are 2 similar existing scripts on userscripts.org. At least mine is the only one that add the Release info to the links ;-).
ShareThis / Compartelo
Estaba buscando como hacer un sleep de 1 minutos en un .bat de Windows (CMD.EXE). Encontre esta forma, es original :-) :
@ ping -n 60 127.0.0.1 > NUL 2>&1
ShareThis / Compartelo
Respecto al post anterior sobre como redistribuir los PV links de un VG sobre los distinctos caminos a los discos, agradezco el comentario de RuBiCK apuntando a la opción -s del comando pvchange:
NAME
pvchange - change characteristics and access path of a physical volume
in an LVM volume group
SYNOPSIS
...
/usr/sbin/pvchange [-A autobackup] -s pv_path
...
-s Immediately begin accessing the associated
physical volume named by pv_path.
...
Usando este comando no es necesario quitar y reañadir los PV links al VG. Ademas de ser mas seguro, tambien se reduce considerablemente el script, quedando asi:
#!/usr/bin/ksh
# Distribuye los PV links sobre las controladoras
set -o nounset
VG=$1
I=0
for PV in $(
vgdisplay -v $VG | grep "PV Name" |
grep -v "Alternate Link" | awk '{ print $3 }' )
do
LISTA_LINKS=$( pvdisplay $PV | grep "PV Name" | awk '{ print $3 }' | sort )
NUM_LINKS=$( echo $LISTA_LINKS | wc -w )
NEW=$(( I % NUM_LINKS + 1 ))
PRI=$( echo $LISTA_LINKS | awk "{ print \$${NEW} }" )
pvchange -A n -s $PRI
(( I = I + 1 ))
done
vgcfgbackup $VG
Gracias RuBiCK por la contribución ;-).
ShareThis / Compartelo
Inspirado por el post de RuBiCK sobre como extender un VG con todos los PV links alternates de cada PV, se me occurrio hacer un script para distribuir todos los PV links sobre los distinctos caminos a los discos (es decir sobre las posibles controladoras). Esto no aplica si estamos usando un drivers que balancea el acceso a los discos y no hace uso de los pv links (por ejemplo Powerpath).
Por ejemplo, un VG de 3 PVs. Cada PV se ve por 4 caminos, por las controladoras c4, c6, c8 y c10.
Posiblemente, el primary path de los 3 PVs sea por la c4, mientras que los demas caminos estan en standby. Aun que no sea comparable a Powerpath, es mas interesante distribuir las I/O sobre todos los caminos posibles. Para esto, podemos redistribuir los primary path sobre los caminos posibles.
Por ejemplo: PV1 por la c4, PV2 por la c6 y PV3 por la c8 (y seguiriamos asi con los demas discos…)
Para hacerlo en caliente, lo que hace el script es quitar los caminos que no seran el primario y reañadirlos (en el orden correcto):
# pvdisplay /dev/dsk/c4t0d4
--- Physical volumes ---
PV Name /dev/dsk/c4t0d4
PV Name /dev/dsk/c6t0d4 Alternate Link
PV Name /dev/dsk/c8t0d4 Alternate Link
PV Name /dev/dsk/c10t0d4 Alternate Link
# vgreduce -A n $VG /dev/dsk/c8t0d4 /dev/dsk/c10t0d4 /dev/dsk/c4t0d4
# vgextend -A n $VG /dev/dsk/c8t0d4 /dev/dsk/c10t0d4 /dev/dsk/c4t0d4
# pvdisplay /dev/dsk/c6t0d4
--- Physical volumes ---
PV Name /dev/dsk/c6t0d4
PV Name /dev/dsk/c8t0d4 Alternate Link
PV Name /dev/dsk/c10t0d4 Alternate Link
PV Name /dev/dsk/c4t0d4 Alternate Link
He hecho el siguiente script para hacer el trabajo automaticamente con todos los discos de un VG:
#!/usr/bin/ksh
# Distribuye los PV links sobre las controladoras
set -o nounset
# bucle para cada primary link:
VG=$1
FILE=$( mktemp )
J=0
for PV in $(
vgdisplay -v $VG | grep "PV Name" |
grep -v "Alternate Link" | awk '{ print $3 }' )
do
(( J = J + 1 ))
I=1
LISTA_LINKS=$( pvdisplay $PV | grep "PV Name" | awk '{ print $3 }' | sort )
NUM_LINKS=$( echo $LISTA_LINKS | wc -w )
for LINK in $( pvdisplay $PV | grep "PV Name" | awk '{ print $3 }' )
do
(( N = ( I + J ) % NUM_LINKS + 1 ))
echo $PV $( echo $LINK | tr "t" "/" | cut -d/ -f 4 ) $LINK $I $N
(( I = I + 1 ))
done
done | sort -k 5 > $FILE
for PV in $(
vgdisplay -v $VG | grep "PV Name" |
grep -v "Alternate Link" | awk '{ print $3 }' )
do
# Lista de links
set -- $( grep $PV" " $FILE | awk '{ print $3 }' )
PRIMARY=$1
shift
ALTERNATES=$*
# esta bien el futur primary? (sino saltamos)
pvdisplay $PRIMARY >/dev/null 2>&1 || continue
vgreduce -A n $VG $ALTERNATES
vgextend -A n $VG $ALTERNATES
done
vgcfgbackup $VG
rm $FILE
ShareThis / Compartelo
Published on
Friday November 16th, 2007 in
Scriptlets.
Este pequeño scriptlet imprime una lista (de item de menos de 20 caracteres) en 4 columnas:
LISTA_IMP="a b c d e f"
I=0
for IMP in $LISTA_IMP
do
(( I = I + 1 ))
printf "%-20s" $IMP
if [ $I -eq 4 ]
then
I=0
echo
fi
done
echo
Me suena que existe algun binario que hace esto, pero no recuerdo cual…
ShareThis / Compartelo
Recent Comments