mirror of
https://github.com/Findus23/RadioStats.git
synced 2024-09-20 17:13:48 +02:00
no empty line at start of sitemap
This commit is contained in:
parent
50cdc7bc11
commit
13e298e772
1 changed files with 6 additions and 15 deletions
21
sitemap.py
21
sitemap.py
|
@ -1,29 +1,20 @@
|
||||||
from peewee import SQL, fn
|
from peewee import SQL, fn
|
||||||
|
|
||||||
xml = """
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
||||||
"""
|
|
||||||
|
|
||||||
from models import Channel, Play, Song
|
from models import Channel, Play, Song
|
||||||
|
|
||||||
|
xml = """<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
"""
|
||||||
|
|
||||||
for channel in Channel.select().where(Channel.has_data == 1):
|
for channel in Channel.select().where(Channel.has_data == 1):
|
||||||
xml += """
|
xml += "<url><loc>https://radiostats.lw1.at/{channel}</loc></url>".format(channel=channel.shortname)
|
||||||
<url>
|
|
||||||
<loc>https://radiostats.lw1.at/{channel}</loc>
|
|
||||||
</url>
|
|
||||||
""".format(channel=channel.shortname)
|
|
||||||
get = Play.select(Play.song, Song.id, fn.Count(SQL('*')).alias("count")) \
|
get = Play.select(Play.song, Song.id, fn.Count(SQL('*')).alias("count")) \
|
||||||
.join(Channel).switch(Play).join(Song) \
|
.join(Channel).switch(Play).join(Song) \
|
||||||
.where((Song.show == 0) & (Channel.shortname == channel.shortname)) \
|
.where((Song.show == 0) & (Channel.shortname == channel.shortname)) \
|
||||||
.group_by(Play.song).order_by(SQL('count').desc()).limit(500)
|
.group_by(Play.song).order_by(SQL('count').desc()).limit(500)
|
||||||
for i in get:
|
for i in get:
|
||||||
song = i.song.id
|
song = i.song.id
|
||||||
xml += """
|
xml += "<url><loc>https://radiostats.lw1.at/{channel}/song/{songid}</loc></url>".format(channel=channel.shortname, songid=song)
|
||||||
<url>
|
|
||||||
<loc>https://radiostats.lw1.at/{channel}/song/{songid}</loc>
|
|
||||||
</url>
|
|
||||||
""".format(channel=channel.shortname, songid=song)
|
|
||||||
|
|
||||||
xml += "</urlset>"
|
xml += "</urlset>"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue