@echo off
cls
echo.
echo Lade und erstelle EPG...
echo.

if exist "merged_epg.xml.gz" del "merged_epg.xml.gz" /s /q >NUL

wget http://rytecepg.ipservers.eu/epg_data/rytecDE_Basic.xz >NUL
wget http://rytecepg.ipservers.eu/epg_data/rytecDE_Common.xz >NUL
wget http://rytecepg.ipservers.eu/epg_data/rytecDE_SportMovies.xz >NUL
wget http://rytecepg.ipservers.eu/epg_data/rytecAT_Basic.xz >NUL
wget http://rytecepg.ipservers.eu/epg_data/rytecCH_Basic.xz >NUL

7z e rytecDE_Basic.xz -aoa >NUL
7z e rytecDE_Common.xz -aoa >NUL
7z e rytecDE_SportMovies.xz -aoa >NUL
7z e rytecCH_Basic.xz -aoa >NUL
7z e rytecAT_Basic.xz -aoa >NUL

ren rytecDE_Basic rytecDE_Basic.xml
ren rytecDE_Common rytecDE_Common.xml
ren rytecDE_SportMovies rytecDE_SportMovies.xml
ren rytecCH_Basic rytecCH_Basic.xml
ren rytecAT_Basic rytecAT_Basic.xml

MergeXMLTV merge.ini epg.xml rytecDE_Basic.xml rytecDE_Common.xml rytecDE_SportMovies.xml rytecCH_Basic.xml rytecAT_Basic.xml >NUL

move /y %~dp0epg.xml %~dp0php\epg.xml >NUL
cd php >NUL
php epg-umlaute.php >NUL
cd %~dp0 >NUL
timeout /T 8 >NUL
move /y %~dp0php\new_epg.xml %~dp0new_epg.xml >NUL
ren "new_epg.xml" "epg.xml" >NUL
if exist "%~dp0php\epg.xml" del "%~dp0php\epg.xml" /s /q >NUL
if exist "%~dp0php\new_epg.xml" del "%~dp0php\new_epg.xml" /s /q >NUL

7z a "epg.xml.gz" "epg.xml" -scs1209 >NUL

if exist "epg.xml" del "epg.xml" /s /q >NUL
if exist "rytec*.xz" del "rytec*.xz" /s /q >NUL
if exist "rytec*.xml" del "rytec*.xml" /s /q >NUL
del merge.ini /s /q >NUL

ren epg.xml.gz merged_epg.xml.gz


echo Fertig. 

goto END

:END

ftp -s:script.ftp

exit