Exemplo n.º 1
0
                track = master.get_current_track_info()
            except Exception as e:
                print("Encountered error in track = master.get_current_track_info(): {e}")
                num_track_errors += 1
                if num_track_errors < 3:
                    time.sleep(1)
                    continue
                else:
                    sys.exit(1)

            title = track.get('title', '')

            position = track.get('position', 0)
            
            if prev_title != title:
                screen_rows = get_screen_size().rows
                need_scroll = False
                duration = track.get('duration', 0)

                artist = track.get('artist', '')
                prev_title = title

                sys.stdout.write("\x1b[2J") #erase screen, go home
                sys.stdout.write("\x1b[H")
                sys.stdout.flush()
      
                lyrics = get_lyrics(artist, title)
                if not lyrics:
                    print("Couldn't retrieve lyrics")
                    continue
Exemplo n.º 2
0
import textwrap
from display_image import show_image, get_screen_size, resize_show_image

db_file = "/home/slzatz/sonos-companion/gr.db"
display_size = 100

conn = sqlite3.connect(db_file)
cur = conn.cursor()

if __name__ == "__main__":
    '''  
    Displays image, quote and bio of select authors
    '''

    line_count = 2
    x = get_screen_size()
    if x.cell_width == 0:
        sys.exit(1)

    # bug that values sometimes 2x what they should be
    if x.cell_width > 12:
        x.width = x.width // 2
        x.height = x.height // 2
        x.cell_width = x.cell_width // 2
        x.cell_height = x.cell_height // 2

    if len(sys.argv) == 1:

        cur.execute(
            "SELECT book_gr_id,quote FROM quotes ORDER BY RANDOM() LIMIT 1;")
        row = cur.fetchone()
Exemplo n.º 3
0
        master = soco.SoCo(speaker)

    prev_title = ""
    prev_artist = ""
    lyrics = ""
    line_num = prev_line_num = 0
    rows = []
    all_rows = []
    img_current = img_previous = image = None
    alpha = 1.1
    need_scroll = False

    print("\x1b[?25l")  # hide cursor

    while 1:
        x = get_screen_size()
        display_size = x.width // 2
        ret = f"\n\x1b[{(display_size//x.cell_width) + 2}C"

        try:
            state = master.get_current_transport_info(
            )['current_transport_state']
        except Exception as e:
            print(
                f"Encountered error in state = master.get_current_transport_info(): {e}"
            )
            state = 'ERROR'
            num_transport_errors += 1
            if num_transport_errors < 3:
                time.sleep(1)
                continue