2016-06-13, 20:03
Recently i download many videos from youtube channel, and i decide to put in my Openelec Kodi. Obviously i want to use EMM to manage them, so i edit a script found here with this one, suitable for my downloaded videos
The tools works really good, but i have problem with Ember in the parsing of nfo file! PS I have the option in settings of Ember to fix the unconform nfo files.
If my NFO file original is this
after the parse of Ember result in:
so basically is the same! infact the video in database is correct, with all field correct!
BUT if my original NFO is this:
after the parse of Ember result in:
you can notice that the aired and plot tag was removed and the video detail was added! In the database there are plot and aired date empty!
I think the problem is the "&" character.
How can i resolve this situation? I find for a solution to write directly the nfo file with the & but i can't fine much.
Thanks in advance for help!
Code:
@echo off & setlocal enabledelayedexpansion
REM Change Season value!!!!
set Season=1
set Basefolder=%cd%
REM Change code page to 65001 (UTF-8)
chcp 65001>NUL
echo.
echo ===========================================================================
echo Creating a .nfo files for each new video. The last used episode
echo number will be stored in the episodecounter.txt for the next time.
echo ===========================================================================
echo.
pushd %Basefolder%
echo Scanning for new videos in %Basefolder% and Subdirectories ...
echo.
REM %recentfolder% is only there to determine if new videos already have been found in this directory.
set recentfolder=
REM Just for the looks... season number is "2 digit 0-prefix"
if %Season% lss 10 (set SeasonNum=0%Season%) else (set SeasonNum=%Season%)
REM For each videofile, found in the Basefolder oder Subfolders ...
for /f "delims=" %%z in ('dir /b /s /O:D *.mkv *.avi *.flv *.mp4 *.wmv *.f4v *.m4v *.mpg *.mpeg') do (
REM Disable Delay Expansion to handle filename or path name containing "!" char
setlocal disabledelayedexpansion
FOR %%A IN (.) DO (
echo %%~nA> _P.txt
)
echo %%~nz> _N.txt
echo %%~xz> _X.txt
echo %%~nxz> _NX.txt
echo %%~dpz> _DP.txt
echo %%~dpnz> _DPN.txt
echo %%z> _DPNX.txt
echo %%~tz> _timestamp.txt
endlocal
(set /p "P=" < _P.txt) & (del /q /f _P.txt)
(set /p "N=" < _N.txt) & (del /q /f _N.txt)
(set /p "X=" < _X.txt) & (del /q /f _X.txt)
(set /p "NX=" < _NX.txt) & (del /q /f _NX.txt)
(set /p "DP=" < _DP.txt) & (del /q /f _DP.txt)
(set /p "DPN=" < _DPN.txt) & (del /q /f _DPN.txt)
(set /p "DPNX=" < _DPNX.txt) & (del /q /f _DPNX.txt)
(set /p "timestamp=" < _timestamp.txt) & (del /q /f _timestamp.txt)
REM Getting Name of TVShow (parent folder)
set "tvshow=!P!"
REM Getting the creation date of the video file, splits it up and uses it as air date.
set "month=!timestamp:~3,2!"
set "year=!timestamp:~6,4!"
set "day=!timestamp:~0,2!"
set "hour=!timestamp:~11,2!"
set "minutes=!timestamp:~14,2!"
REM Checking whether an episode counter file exists. If not it generates one starting with zero.
if not exist episodecounter.txt (
echo 0 > episodecounter.txt
)
REM Checking wheter a tvshow.nfo exists
if not exist "!DP!tvshow.nfo" (
echo.
echo ---------------------------------------------------------------------------
echo New folder "!tvshow!" found. tvshow.nfo generated
echo ---------------------------------------------------------------------------
echo.
REM Writing a basic XML structure to the tvshow.nfo just using the folder name as a title.
REM Codepage 65001 is needed, if there are special Chars / UTF-8 Chars in the filename like äöüß 인피니트 اللَّهِ
echo ^<^?xml version=^"1.0^" encoding=^"UTF-8^" standalone=^"yes^"^?^>> "!DP!tvshow.nfo"
echo ^<tvshow^>>> "!DP!tvshow.nfo"
echo ^<title^>!tvshow!^</title^>>> "!DP!tvshow.nfo"
echo ^<genre^>Cooking^</genre^>>> "!DP!tvshow.nfo"
echo ^<season^>!Season!^</season^>>> "!DP!tvshow.nfo"
echo ^<plot^>Food that^'ll make you close your eyes, lean back, and whisper yessss. Snack-sized videos and recipes you^'ll want to try.^</plot^>>> "!DP!tvshow.nfo"
echo ^</tvshow^>>> "!DP!tvshow.nfo"
)
REM Checking for (new) video files without according .nfo
if not exist "!N!.nfo" (
REM is that video the first new video, found in this directory?
if not "!DP!" == "!recentfolder!" (
echo.
echo ---------------------------------------------------------------------------
echo New video^(s^) found in "!DP!"
echo ---------------------------------------------------------------------------
echo.
)
REM Using the last known episode number in each folder and sets it +1.
set /p "Episode=" < episodecounter.txt
set /A Episode +=1
REM Just for the looks... episode number is "3 digit 0-prefix"
if !Episode! lss 10 (set EpisodeNum=00!Episode!) else (if !Episode! lss 100 (set EpisodeNum=0!Episode!) else (set EpisodeNum=!Episode!))
REM Writing a basic XML structure to the according .nfo just using the file name as a title.
echo ^<^?xml version=^"1.0^" encoding=^"UTF-8^" standalone=^"yes^"^?^>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^<episodedetails^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^<title^>!N!^</title^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^<aired^>!year!-!month!-!day!^</aired^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^<season^>!Season!^</season^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^<plot^>!N!^</plot^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^<dateadded^>!year!-!month!-!day! !hour!:!minutes!:00^</dateadded^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
echo ^</episodedetails^>>> "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!.nfo"
REM Renaming the video file by adding season and episode
rename "!NX!" "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!!X!"
REM If there is already a .jpg, rename it
if exist "!N!.jpg" rename "!N!.jpg" "!tvshow!.S!SeasonNum!E!EpisodeNum!.!N!-thumb.jpg">nul
chcp 850>NUL
rem Change code page to 65001 (UTF-8)
chcp 65001>NUL
REM Writes the last used episode number into a .txt for later use
echo !Episode! > episodecounter.txt
set recentfolder=!DP!
)
)
popd
echo.
echo Completato
chcp 850>NUL
rem Auto exit in 5 seconds
timeout 5
endlocal
goto:eof
The tools works really good, but i have problem with Ember in the parsing of nfo file! PS I have the option in settings of Ember to fix the unconform nfo files.
If my NFO file original is this
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<episodedetails>
<title>Brownie Tiramisu</title>
<aired>2016-06-11</aired>
<season>1</season>
<plot>Brownie Tiramisu</plot>
<dateadded>2016-06-11 09:30:00</dateadded>
</episodedetails>
after the parse of Ember result in:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<episodedetails>
<title>Brownie Tiramisu</title>
<aired>2016-06-11</aired>
<season>1</season>
<plot>Brownie Tiramisu</plot>
<dateadded>2016-06-11 09:30:00</dateadded>
</episodedetails>
so basically is the same! infact the video in database is correct, with all field correct!
BUT if my original NFO is this:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<episodedetails>
<title>Baked Ham & Cheese Ring</title>
<aired>2016-06-11</aired>
<season>1</season>
<plot>Baked Ham & Cheese Ring</plot>
<dateadded>2016-06-11 09:30:00</dateadded>
</episodedetails>
after the parse of Ember result in:
Code:
<?xml version="1.0" encoding="utf-8"?>
<episodedetails>
<title>Baked Ham & Cheese Ring</title>
<season>1</season>
<episode>262</episode>
<fileinfo>
<streamdetails>
<audio>
<channels>2</channels>
<codec>aac</codec>
</audio>
<video>
<aspect>1.779</aspect>
<codec>h264</codec>
<durationinseconds>53</durationinseconds>
<height>480</height>
<scantype>Progressive</scantype>
<width>854</width>
<filesize>4610964</filesize>
</video>
</streamdetails>
</fileinfo>
<dateadded>2016-06-11 09:30:00</dateadded>
</episodedetails>
you can notice that the aired and plot tag was removed and the video detail was added! In the database there are plot and aired date empty!
I think the problem is the "&" character.
How can i resolve this situation? I find for a solution to write directly the nfo file with the & but i can't fine much.
Thanks in advance for help!