Skip to content

Instantly share code, notes, and snippets.

@sanchon
Created August 15, 2014 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanchon/83a6a9dc148f5af06296 to your computer and use it in GitHub Desktop.
Save sanchon/83a6a9dc148f5af06296 to your computer and use it in GitHub Desktop.
Bajar Subtítulos de Series On Deck
.headers OFF
.output ficherosondecksubs.txt
select distinct P.file --, IAbuelo.title as serie, IPadre.[index] as temporada, I.[index] as episodio
from METADATA_ITEMS I
inner join LIBRARY_SECTIONS L
on I.library_section_id = L.id
left outer join METADATA_ITEM_SETTINGS S
on I.guid = S.guid
inner join MEDIA_ITEMS M
on I.id = M.metadata_item_id
inner join MEDIA_PARTS P
on M.id = P.media_item_id
left outer join METADATA_ITEMS IPadre
on I.parent_id = IPadre.id
left outer join METADATA_ITEMS IAbuelo
on IPadre.parent_id = IAbuelo.id
where ( S.view_count = 0 or S.view_count is null)
and L.name in
("03 TVShows")
and (
IPadre.[index]*100 + I.[index] in
(
select IPadre2.[index] * 100 + I2.[index]
from METADATA_ITEMS I2
inner join LIBRARY_SECTIONS L2
on I2.library_section_id = L2.id
left outer join METADATA_ITEM_SETTINGS S2
on I2.guid = S2.guid
inner join MEDIA_ITEMS M2
on I2.id = M2.metadata_item_id
inner join MEDIA_PARTS P2
on M2.id = P2.media_item_id
left outer join METADATA_ITEMS IPadre2
on I2.parent_id = IPadre2.id
left outer join METADATA_ITEMS IAbuelo2
on IPadre2.parent_id = IAbuelo2.id
where IAbuelo.id = IAbuelo2.id
and ( S2.view_count = 0 or S2.view_count is null)
order by 1
limit 1
)
or
IAbuelo.id is null
)
;
.quit
# ruta de la b.d. de Plex Media Server
RUTABD="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
# ejecucion de la query en sqlite
cat queryFicherosOnDeckSubs.sql | sqlite3 "$RUTABD"
# me bajo los subtitulos de todos los ficheros de la lista
while read unfichero; do
# borro los subtitulos que haya...
sinextension=${unfichero%.*}
rm "$sinextension"*srt
subliminal -l en es -- "$unfichero"
done < "ficherosondecksubs.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment