Exemplo n.º 1
0
    def on_get(self, request, response):
        channels = Channel.select()
        body = {}

        body["count"] = channels.count()
        body["channels"] = [channel.name for channel in channels]

        response.body = json.dumps(body)
        response.status = falcon.HTTP_200
Exemplo n.º 2
0
 def _load(self, dictt, Classs):
     is_subscribed = True
     for channel in list(Channel.select().where(
         (Channel.is_subscribed == is_subscribed))):
         if channel.slack_id not in dictt:
             dictt[channel.slack_id] = Classs(
                 **{
                     'channel_id': channel.id,
                     'slack': self.slack,
                     'profanity_filter_on': self.profanity_filter_on,
                     'bot_slack_id': self.bot_slack_id,
                     'bot_slack_name': self.bot_slack_name,
                     'bot_icon_emoji': self.bot_icon_emoji,
                     'bot_icon_url': self.bot_icon_url
                 })
Exemplo n.º 3
0
 def start(self):
   self.database_manager.connect()
   self.database_manager.create_tables(Base)
   self._initialize_channels_and_users()
   self._create_slackotron_user()
   self.info('Users:')
   for user in User.select():
     self.info(user)
   self.info('Channels:')
   for channel in Channel.select():
     self.info(channel)
   self.plugin_manager.start_plugins()
   self.thread_manager.start_threads()
   self.dashboard_manager.start_dashboard()
   self.run()
def extract_blacklist():
    # region = Region.get(Region.region_id == 'TW')
    # channels = Channel.select().where(Channel.country == region)
    channels = Channel.select()
    blacklist_tags = []
    for c in tqdm(channels):
        videos = Video.select().where(Video.channel == c)
        tags = []
        count = 0
        for v in videos:
            tags += v.tags
            count += 1
        counter = Counter(tags)
        for key, value in counter.items():
            if value >= count*0.7 and count > 3:
                blacklist_tags.append(key)
    blacklist_tags = list(set(blacklist_tags))
    with open('video_blacklist_tag_0.7.txt', 'w') as f:
        for key in blacklist_tags:
            f.write('{}\n'.format(key))
Exemplo n.º 5
0
def list_channel(search: str = None, country: str = None, offset=0):

    channel_query = Channel.select(Channel.channel_id, Channel.title,
                                   Channel.description, Channel.country)

    if search is not None:
        print(search)
        search = str(search)
        channel_query = channel_query.where(
            Match(Channel.title, search) | Match(Channel.description, search))

    if country is not None:
        print('search country')
        region = Region.get(Region.region_id == country)
        channel_query = channel_query.where(Channel.country == region)

    channels = []
    for idx, c in enumerate(channel_query[offset:]):
        json_data = model_to_dict(c)
        channels.append(json_data)
        if idx > 10:
            break

    return {'count': len(channels), 'channels': channels}
Exemplo n.º 6
0
 def _unload(self, dictt):
     is_subscribed = False
     for channel in list(Channel.select().where(
         (Channel.is_subscribed == is_subscribed))):
         if channel.slack_id in self.subscribers:
             del dictt[channel.slack_id]
Exemplo n.º 7
0
 def _start_slackotron_threads(self):
     for channel in Channel.select():
         for _type in self.thread_types:
             params = {'channel_id': channel.get_id()}
             self._start_slackotron_thread(_type, **params)
Exemplo n.º 8
0
from peewee import SQL, fn

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):
    xml += "<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")) \
        .join(Channel).switch(Play).join(Song) \
        .where((Song.show == 0) & (Channel.shortname == channel.shortname)) \
        .group_by(Play.song).order_by(SQL('count').desc()).limit(500)
    for i in get:
        song = i.song.id
        xml += "<url><loc>https://radiostats.lw1.at/{channel}/song/{songid}</loc></url>".format(
            channel=channel.shortname, songid=song)

xml += "</urlset>"

with open('sitemap.xml', 'w') as file:
    file.write(xml)