Esempio n. 1
0
    def add_tracks(self):
        """Append tracks to the queue.

        Previously, new playlists were retrieved by incrementing the
        current show ID, but incrementing is not guaranteed to yield
        a valid playlist and it leads to an infinite loop if no valid
        playlists are found up to the present, so now a random show ID
        is selected every time. Since shows are not scheduled according
        to genre continuity, selecting a random show every time has no
        less continuity than incrementing.
        """
        begin_index = len(self._queue)

        while len(self._queue) < PLAYLIST_MIN_LENGTH:
            # retrieve playlist from database
            self._show_id = database.get_new_show_id(self._show_id)

            if self._show_id is -1:
                time.sleep(1.0)

            playlist = database.get_playlist(self._show_id)

            # add each track whose artist isn't already in the queue or played list
            self._queue.extend([t for t in playlist if not is_artist_in_list(t, self._played) and not is_artist_in_list(t, self._queue)])

            print time.asctime() + " :=: CartQueue :: Added tracks, length is " + (str)(len(self._queue))

        self._gen_start_times(begin_index)
Esempio n. 2
0
    def add_tracks(self):
        """Append tracks to the queue.

        Previously, new playlists were retrieved by incrementing the
        current show ID, but incrementing is not guaranteed to yield
        a valid playlist and it leads to an infinite loop if no valid
        playlists are found up to the present, so now a random show ID
        is selected every time. Since shows are not scheduled according
        to genre continuity, selecting a random show every time has no
        less continuity than incrementing.
        """
        begin_index = len(self._queue)

        while len(self._queue) < PLAYLIST_MIN_LENGTH:
            # retrieve playlist from database
            self._show_id = database.get_new_show_id(self._show_id)

            if self._show_id is -1:
                time.sleep(1.0)

            playlist = database.get_playlist(self._show_id)

            # add each track whose artist isn't already in the queue or played list
            self._queue.extend([t for t in playlist if not is_artist_in_list(t, self._played) and not is_artist_in_list(t, self._queue)])

            print time.asctime() + " :=: CartQueue :: Added tracks, length is " + (str)(len(self._queue))

        self._gen_start_times(begin_index)
Esempio n. 3
0
 def addPlaylistToQueue(self):
     for index in sorted(self.playlistList.selectionModel().selectedRows()):
         dt = db.get_playlist(self.playlistListModel.getId(index))
         for line in dt:
             self.playlist.addMedia(
                 QMediaContent(QUrl.fromLocalFile(line[1])))
     self.playlistModel.layoutChanged.emit()
Esempio n. 4
0
def wait_for_picture(message):
    if message.photo is None:
        bot.send_message(message.chat.id,
                         "Hmmm... pretty sure that's not a picture")
    else:
        file_info = bot.get_file(message.photo[0].file_id)
        url = "https://api.telegram.org/file/bot" + config.bot_token + "/" + file_info.file_path
        bot.send_chat_action(message.chat.id, 'typing')
        image = np.asarray(bytearray(requests.get(url).content), dtype="uint8")
        image = cv2.imdecode(image, cv2.IMREAD_COLOR)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
        hist = cv2.calcHist([image], [0, 1], None, [200, 128],
                            [0, 360, 0, 256])
        hist = cv2.normalize(hist, hist).flatten()
        results = {}
        for row in database.get_color_histograms():
            row_hist = np.asarray(row[1], dtype=np.float32)
            distance = cv2.compareHist(hist, row_hist,
                                       cv2.HISTCMP_BHATTACHARYYA)
            results[row[0]] = distance
        results = sorted([(v, k) for (k, v) in results.items()])
        results = database.get_playlist(results[0][1])
        res = print_result(results)
        bot.send_photo(message.chat.id, requests.get(results[5]).content)
        bot.send_message(message.chat.id, res, parse_mode='HTML')
Esempio n. 5
0
def single_playlist(playlist_id):

    page['title'] = 'Playlist'

    playlist = None
    playlist = database.get_playlist(playlist_id)

    playlist_songs = None
    playlist_songs = database.get_playlist_songs(playlist_id)

    # Data integrity checks
    if playlist == None:
        playlist = []

    if playlist_songs == None:
        playlist_songs = []

    return render_template('singleitems/playlist.html',
                           session=session,
                           page=page,
                           user=user_details,
                           playlist=playlist,
                           playlist_songs=playlist_songs)
Esempio n. 6
0
#!/usr/bin/env python

"""Test suite for the database module."""
import sys
sys.path.insert(0, 'app')

import database

print database.get_new_show_id(-1)
print database.get_cart("PSA")
print database.get_cart("Underwriting")
print database.get_cart("StationID")
print database.get_cart("Promotion")
print database.get_playlist(25608)

print database.get_carts()

print database.search_library("mings")

# print database.log_cart()