Střih provádím v iMovie, následuje přímo export do iTunes. V iTunes video označím jako TV Show a doplním další informace (např. Show = Rodinné video, rok, popis atd.)
2. DVD, mkv, avi a jiné
Film převedu do m4v s pomocí Handbrake. Používám přednastavený profil Apple TV 2, FPS "Same as source", zaškrtnuto "Web optimized".
Pokud chci k výslednému souboru přidat titulky, používám program Subler, který umožňuje práci s jednotlivými streamy v m4v kontejneru, přidání titulků ze srt souboru, generování kapitol a případnou optimalizaci pro streamování.
Doplnění informací (herci, režie, rok, obrázek) provádím po přidání filmu do iTunes. Používám vlastní applescript, který vyhledá na Internetu (csfd.cz) pomocí Safari požadované informace a doplní metadata do souboru. Klíčem k vyhledání filmu je jeho název.
Skript je nutné uložit do ~/Library/iTunes/Scripts/
Ukázka applescriptu:
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on waitForPage()
delay 6
tell application "Safari"
set x to 0
repeat until ((do JavaScript "document.readyState" in front document) is "complete")
set x to x + 1
if (x mod 20 is 0) then do JavaScript "window.location.reload()" in front document
delay 1
end repeat
delay 1
end tell
end waitForPage
on run
tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...
set sel to a reference to selection
repeat with aTrack in sel
set fName to name of aTrack
set fDirectors to ""
set fActors to ""
set fPlots to ""
set fGenre to ""
set fOrigin to ""
set iRating to "0"
set ffilm to ""
set fTitle to ""
set originItems to {}
set fSearch to {}
set fSearchName to {}
set fImg to my pathForTemporaryFile(false)
tell application "Safari"
open location "http://www.csfd.cz/hledat/?q=" & fName
my waitForPage()
set fTitle to do JavaScript "document.getElementsByTagName('title')[0].innerText" in document 1
if (fTitle is "Vyhledávání | ČSFD.cz") then
-- je-li vice vysledku, nechame uzivatele vybrat
-- pocet vysledku
set sRes to (do JavaScript "document.getElementById('search-films').getElementsByTagName('h3').length" in document 1) as number
set i to 0
if sRes is 0 then
exit repeat
end if
repeat sRes times
set end of fSearch to do JavaScript "document.getElementById('search-films').getElementsByTagName('h3')[" & i & "].getElementsByTagName('a')[0].href" in document 1
set tmpSearchName to do JavaScript "document.getElementById('search-films').getElementsByTagName('li')[" & i & "].innerText" in document 1
set AppleScript's text item delimiters to (ASCII character 10)
set theTextList to text items of tmpSearchName
set AppleScript's text item delimiters to ","
set newText to theTextList as text
set AppleScript's text item delimiters to ""
set end of fSearchName to "" & i & ": " & (text 2 thru ((length of newText) - 1) of newText)
set i to i + 1
end repeat
set selectedFilm to (choose from list fSearchName without multiple selections allowed)
if selectedFilm is not false then
set sFilmItem to text 1 thru ((offset of ":" in (item 1 of selectedFilm)) - 1) of item 1 of selectedFilm
set ffilm to item ((sFilmItem as integer) + 1) of fSearch
-- set ffilm to do JavaScript "document.getElementById('search-films').getElementsByTagName('h3')[0].getElementsByTagName('a')[0].href" in document 1
close document 1
open location ffilm
my waitForPage()
else
exit repeat
end if
end if
set fGenre to do JavaScript "document.getElementById('profile').getElementsByClassName('genre')[0].innerText" in document 1
set fOrigin to do JavaScript "document.getElementById('profile').getElementsByClassName('origin')[0].innerText" in document 1
set fDirectors to do JavaScript "document.getElementById('profile').getElementsByClassName('directors')[0].getElementsByTagName('span')[0].innerText" in document 1
set fActors to do JavaScript "document.getElementById('profile').getElementsByClassName('actors')[0].getElementsByTagName('span')[0].innerText" in document 1
set fPlots to do JavaScript "document.getElementById('plots').getElementsByClassName('content')[0].innerText" in document 1
set fRating to do JavaScript "document.getElementById('rating').getElementsByTagName('h2')[0].innerText" in document 1
set iRating to text 1 thru ((offset of "%" in fRating) - 1) of fRating
set fImgURL to do JavaScript "document.getElementById('poster').getElementsByTagName('img')[0].src" in document 1
-- obrazek. Vezmeme 1. plakat
tell application "URL Access Scripting"
download fImgURL to file fImg
end tell
close document 1
end tell
set artist of aTrack to fDirectors
set album artist of aTrack to fActors
set long description of aTrack to fPlots
set genre of aTrack to fGenre
set description of aTrack to fPlots
set comment of aTrack to fOrigin & (ASCII character 10) & fPlots
try
set rating of aTrack to (iRating as integer)
end try
set AppleScript's text item delimiters to ","
set originItems to text items of fOrigin
set AppleScript's text item delimiters to {""}
set year of aTrack to item 2 of originItems
set artworkCount to count of artwork of aTrack
set myArt to read (file fImg) as picture
set data of artwork 1 of aTrack to myArt
try
tell application "Finder"
if exists file fImg then
delete file fImg -- moves it to the trash
end if
end tell
end try
end repeat
end if
end tell
end run
on pathForTemporaryFile(_folderName)
(*
Generates a unique path for a file in the
current user's temporary items folder.
Takes a single argument that can be set
to the name of a subfolder or false to
create no subfolder.
*)
-- Create timestamp
set _date to current date
set _month to month of _date as integer
set _day to day of _date
set _year to year of _date as string
set _time to (time of _date)
set _hour to _time div (60 * 60)
set _minute to _time mod (60 * 60) div 60
set _second to _time mod 60
if _month is less than 10 then
set _month to "0" & (_month as string)
else
set _month to _month as string
end if
if _day is less than 10 then
set _day to "0" & (_day as string)
else
set _day to _day as string
end if
if _hour is less than 10 then
set _hour to "0" & (_hour as string)
else
set _hour to _hour as string
end if
if _minute is less than 10 then
set _minute to "0" & (_minute as string)
else
set _minute to _minute as string
end if
if _second is less than 10 then
set _second to "0" & (_second as string)
else
set _second to _second as string
end if
set _timestamp to _year & _month & _day & _hour & _minute & _second
-- Generate pseudorandom numbers
set _rand1 to (round (random number from 100 to 999)) as string
set _rand2 to (round (random number from 100 to 999)) as string
set _rand3 to (round (random number from 100 to 999)) as string
set _rand4 to (round (random number from 100 to 999)) as string
set _randomString to _rand1 & _rand2 & _rand3 & _rand4
-- Create file name
set _fileName to ((_timestamp & _randomString) as string)
-- Get the path to the parent folder
set _temporaryFolderPath to path to temporary items folder from user domain as string
if _folderName is false then
set _parentFolderPath to _temporaryFolderPath
else
set _parentFolderPath to _temporaryFolderPath & _folderName & ":"
tell application "System Events" to if (exists folder _parentFolderPath) is false then make new folder at the end of folders of folder _temporaryFolderPath with properties {name:_folderName}
end if
-- Make sure the file does not exist
set _rNumber to 1
repeat
if _rNumber is 1 then
set _tempFilePath to _parentFolderPath & _fileName
else
set _tempFilePath to _parentFolderPath & _fileName & "_" & (_rNumber as string)
end if
tell application "System Events" to if (exists file _tempFilePath) is false then exit repeat
set _rNumber to _rNumber + 1
end repeat
return _tempFilePath
(*
Copyright (C) 2011 by Adrian Nier (http://www.mac-spezialist.de/code)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*)
ahoj,
OdpovědětVymazatdal by se někde skcript získat? děkuji míra
Dobrý den, zkoušel jsem váš skript pro stažení informací k filmu z ČSFD, ale program mi padá na řádku
OdpovědětVymazat"set artist of aTrack to fDirectors" s chybou "The variable fDirectors is not defined". Což je zláštní, protože tato proměnná se vytváří v každém průchodu cyklem. V applescriptu jsem naprostý začátečník (programuji v C#), takže pokud byste mi v tomto poradil, byl bych vám vděčný :). Děkuji, Petr.
da se nekde script ziskat?
OdpovědětVymazat