im trying to make some sort of automated rss updater for a local rtmp server and i thought that the easiest way to do it is to make one or two batch files and let them run every minute via windows Task Scheduler.
我试图为本地rtmp服务器制作某种自动rss更新程序,我认为最简单的方法是制作一个或两个批处理文件,让它们通过Windows任务计划程序每分钟运行一次。
This server records flv and mp4 files in a dir and i have embedded jwplayer on that local server. The playlists of that player are feeded via a rss file and i want them to update automaticly.
这个服务器在dir中记录了flv和mp4文件,我在该本地服务器上嵌入了jwplayer。该播放器的播放列表通过rss文件提供,我希望它们自动更新。
The first batchfile was easy
第一个批处理文件很简单
del RssRaw.txt dir /b > RssRaw.txt
del RssRaw.txt dir / b> RssRaw.txt
the 2nd is the one that i'm just clueless about and would like to ask help.
第二个是我只是一无所知,想要求帮助。
i would like it to parse every single line of the RssRaw.txt file and saves it in a rss/xml file in the following format:
我希望它解析RssRaw.txt文件的每一行,并以下列格式将其保存在rss / xml文件中:
<rss version="2.0" xmlns:jwplayer="http://rss.jwpcdn.com/">
<channel>
<item>
<title> #1 </title>
<jwplayer:source file="/assets/#1.1" />
</item>
<item>
<title> #2 </title>
<jwplayer:source file="/assets/#2.1" />
</item>
</channel>
</rss>
Where #1 is the just filename and #1.1 the filename with the extention (.flv or .mp4) And where #2 and #2.1 is the next line/file.
其中#1是正确的文件名,#1.1是带有扩展名的文件名(.flv或.mp4)而#2和#2.1是下一行/文件。
I hope it's possible to auto-generate the tags based on how many lines there are in the RssRaw.txt
我希望可以根据RssRaw.txt中有多少行来自动生成标签
It will be helpfull if i can exclude certain lines/words that are in the batchfile because with this setup it will also list the text and batch files in the RssRaw.txt
如果我可以排除批处理文件中的某些行/单词将会有所帮助,因为使用此设置它还将列出RssRaw.txt中的文本和批处理文件
Can anyone help me or point me in the right direction or even know if this is possible in a batch file? Or possibly has a better solution that this?
任何人都可以帮助我或指出我正确的方向,甚至知道这是否可以在批处理文件中?或者可能有更好的解决方案呢?
( please keep in mind that im trying to make this a local server so thats why i didn't look at webservices).
(请记住,我试图使这个本地服务器,这就是为什么我没有看到webservices)。
1 个解决方案
#1
0
this reads the files directly from the directory, you don't need the first batch:
这直接从目录中读取文件,您不需要第一批:
@ECHO OFF &SETLOCAL
SET "header1=<rss version="2.0" xmlns:jwplayer="http://rss.jwpcdn.com/">"
SET "header2= <channel>"
SET "footer1= </channel>"
SET "footer2=</rss>"
(
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO(!header1!
ECHO(!header2!
ECHO(
ENDLOCAL
FOR %%a IN (*.flv *.mp4) DO (
ECHO( ^<item^>
ECHO( ^<title^> %%~na ^</title^>
ECHO( ^<jwplayer:source file="/assets/%%~nxa" /^>
ECHO( ^</item^>
)
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO(
ECHO(!footer1!
ECHO(!footer2!
)>outfile.rss
Nevertheless if you want to read from file, replace the FOR
loop code with this:
不过,如果你想从文件中读取,请用以下代码替换FOR循环代码:
FOR /f %%a IN (RssRaw.txt) DO (
#1
0
this reads the files directly from the directory, you don't need the first batch:
这直接从目录中读取文件,您不需要第一批:
@ECHO OFF &SETLOCAL
SET "header1=<rss version="2.0" xmlns:jwplayer="http://rss.jwpcdn.com/">"
SET "header2= <channel>"
SET "footer1= </channel>"
SET "footer2=</rss>"
(
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO(!header1!
ECHO(!header2!
ECHO(
ENDLOCAL
FOR %%a IN (*.flv *.mp4) DO (
ECHO( ^<item^>
ECHO( ^<title^> %%~na ^</title^>
ECHO( ^<jwplayer:source file="/assets/%%~nxa" /^>
ECHO( ^</item^>
)
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO(
ECHO(!footer1!
ECHO(!footer2!
)>outfile.rss
Nevertheless if you want to read from file, replace the FOR
loop code with this:
不过,如果你想从文件中读取,请用以下代码替换FOR循环代码:
FOR /f %%a IN (RssRaw.txt) DO (