Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jimu-gh/Kashi

Touch Bar widget that displays the lyrics of the current song in Spotify, Music, or YouTube. Written in Python, AppleScript, and JavaScript.
https://github.com/jimu-gh/Kashi

Last synced: about 9 hours ago
JSON representation

Touch Bar widget that displays the lyrics of the current song in Spotify, Music, or YouTube. Written in Python, AppleScript, and JavaScript.

Awesome Lists containing this project

README

        

KASHI · 歌詞 · かし

![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)
![love](http://forthebadge.com/images/badges/built-with-love.svg)

![build](https://img.shields.io/badge/build-passing-brightgreen.svg?style=for-the-badge) ![license](https://img.shields.io/badge/license-GPLv3-blue.svg?style=for-the-badge) ![license](https://img.shields.io/badge/PRs-welcome-yellow.svg?style=for-the-badge)

## About Kashi

Kashi is a custom [BetterTouchTool](https://folivora.ai/) widget that displays the current song lyrics on the Macbook Pro's Touch Bar.

Kashi works with [Spotify](https://www.spotify.com/us/download/other/), [Music](https://www.apple.com/music/), and [Youtube](https://www.youtube.com) (Chrome or Safari).

Kashi has three main functions:
1. It retrieves data about the current song playing in Spotify, Music, or YouTube via AppleScript.
2. It calls [Genius](https://docs.genius.com/) and checks for a good match in the search hits, accounting for variations such as remixes.
3. It scrapes the lyrics from the raw HTML of the Genius URL, prettifies, and outputs them onto the Touch Bar.

Regarding YouTube:
1. YouTube must be playing on the active tab on Chrome or Safari, with window focus.
2. If both browser and player are open, Kashi will prioritize the player if it is playing.

## Installation

### Step 1: Install BetterTouchTool

BetterTouchTool can be downloaded [here](https://folivora.ai/downloads). To install, unzip the download file and move the application file to your Applications folder.

### Step 2: Install Python 3 and Packages

Install [Python 3](https://www.python.org/downloads/release/python-371/) and the Python packages below.

For help with package installation, please refer to the [Python Packaging User Guide](https://packaging.python.org/tutorials/installing-packages/).

- [OSAscript](https://pypi.org/project/osascript/)

`pip install osascript` or `pip3 install osascript`
- [Requests](https://pypi.org/project/requests/)

`pip install requests` or `pip3 install requests`
- [BeautifulSoup](https://pypi.org/project/beautifulsoup4/)

`pip install beautifulsoup4` or `pip3 install beautifulsoup4`

### Step 3: Import Kashi.json into BetterTouchTool

Open BetterTouchTool Configuration, accessible via the top menu bar.

Open BTT Configuration

Confirm that you are in the Touch Bar Settings.

Touch Bar Settings

Open [`kashi.json`](/kashi.json) in a text editor. Select all (⌘A) and copy (⌘C).

Select / Copy JSON

Click somewhere on the trigger list (left column, striped), and Paste (⌘V) directly into the BetterTouchTool Configuration window. The new widget will appear in your list.

Paste JSON Into BTT Configuration Window

Depending on how your Python is installed, the widget may already be working. If not, do Step 4 below to configure the widget's parameters.

### Step 4: Set Widget Parameters

The Launch Path parameter must direct to your Python 3 install. [PATH](https://bic-berkeley.github.io/psych-214-fall-2016/using_pythonpath.html) will also work.

   Default - "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

The second parameter must refer to Python's "site-packages" folder containing Python modules.

   Default - "/Library/Frameworks/Python.Framework/Versions/3.7/lib/Python3.7/site-packages"

Lyrics for the currently playing song should now appear on the Touch Bar. Enjoy! 🎉

## History

   11.30.19 Updated for macOS Catalina

   6.23.19 YouTube and browser support added

   12.03.18 Initial release

## Resources

For detailed information about Touch Bar customization, please refer to the official [BTT Documentation](https://docs.bettertouchtool.net/docs/402_touch_bar_basics.html).

More awesome Touch Bar presets can be found on the [BTT Community](https://community.folivora.ai/).

ChengHaoMou's [Touchbar-Lyric](https://github.com/ChenghaoMou/touchbar-lyric) is a similarly inspired widget accessing NetEase's API for real-time lyrics display.

## Contact

[LinkedIn](https://www.linkedin.com/in/hojim)

[Homepage](https://www.jimho.us)