Skip to main content

gdriveaudio

Play audio files in the google drive.

Requirments

  • Python3
  • MPlayer and FFmpeg
    • Ubuntu: sudo apt install mplayer ffmpeg
    • MacOSX: brew install mplayer ffmpeg
    • Windows: Follow official instructionat MPlayer and FFmpeg
  • Google account, access to the google cloud platform

Set up with Google cloud

Enable google drive API

  • Log in to the google cloud console and create or choose the project to use.
  • Go to Google Drive API page and enable it.

Create a service account to access google drive

  • Log in to the google cloud console and create or choose the project to use.
  • Go to IAM & Admin > Service Accounts.
  • Click "CREATE SERVICE ACCOUNT".
  • Type in an arbitrary service account name (e.g. gdriveaudio-sa).
  • Click "DONE".
  • Note the email address of the service account name (e.g. gdriveaudio-sa@gdriveaudio-project.iam.gserviceaccount.com).

Give the service account the access to the music folder

  • Open Google Drive.
  • Open the folder that contains music files.
  • Click the folder name and choose "Share".
  • Paste the email address of the service account noted in the previous step.
  • Click "Done".

Create the credentials file of the service account

  • Log in to the google cloud console and choose the project to use.
  • Open IAM & Admin > Service Accounts.
  • Click the service account created above.
  • Click "KEYS" in the top menu.
  • Click "ADD KEY" and then "Create new key"
  • Choose "JSON" key type and click "CREATE".
  • Rename the downloaded file as _credentials.json and move to a folder to use for this tool.

Install

# from pypi
$ pip3 install gdriveaudio

# from github
$ git clone --depth=1 https://github.com/kota7/gdriveaudio.git
$ pip3 install -U ./gdriveaudio

Start playing

For the program to locate the credential file, either

  • Run the commands in the folder that has the "_credentials.json"
  • Set GDRIVEAUDIO_DIRECTORY environment variable as the directory containing "_credentials.json", or
  • Run the commands with --workdir={directory} option to specify the directory containing "_credentials.json"
# Initialize data
#   Delete pre-fetched data
#   Create SQLite database file '_gdriveaudio.db'
$ gdriveaudio init

# Update data
#   -U for updating file list
#   -F for updating folder structure information
#   -M for updating audio metadata (this can take hours)
$ gdriveaudio update -UF
# or
$ gdriveaudio update -UFM

# Play all files
$ gdriveaudio play 
# Play files with some condition
#   -k: case-insensitive keywords to search
#   -K: case-sensitive keywords to search
#   -q: Query inside 'WHERE' condition (follow SQLite dialect)
$ gdriveaudio play -k "beethoven"
$ gdriveaudio play -K "Michael J"       # case sensitive search
$ gdriveaudio play -k "name:lucky"      # search only inside 'name' field
$ gdriveaudio play -q "duration > 600"  # 10+ min only

# Show data
# -k, -K, -q filters also work
$ gdriveaudio data -n 5
$ gdriveaudio data -n 10 -k "beethoven"

# See full command options
$ gdriveaudio -h
$ gdriveaudio {init,update,play,data} -h

The audio player can be controled by key strokes (See full description at man mplayer):

 <-  or  ->       seek backward/forward 10 seconds
 down or up       seek backward/forward  1 minute
 pgdown or pgup   seek backward/forward 10 minutes
 < or >           step backward/forward in playlist
 p or SPACE       pause movie (press any key to continue)
 q or ESC         stop playing and quit program
 + or -           adjust audio delay by +/- 0.1 second
 o                cycle OSD mode:  none / seekbar / seekbar + timer
 * or /           increase or decrease PCM volume
 x or z           adjust subtitle delay by +/- 0.1 second
 r or t           adjust subtitle position up/down, also see -vf expand

Release files for gdriveaudio 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gdriveaudio 0.1.15
File Size Uploaded
gdriveaudio-0.1.15.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gdriveaudio 0.1.15
File Interpreter ABI Platform
gdriveaudio-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / gdriveaudio-0.1.15.tar.gz

Download URL gdriveaudio-0.1.15.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9ced63b251018fc7816db10a3848deac18572c4181a094566356f4ef01df9a5e
BLAKE2b-256 checksum
How to use checksums
2c1bb67f8ace4cbe875a3bd2289b61d3b2551072b9110dbcd56bf7088a72c46d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Release files / gdriveaudio-0.1.15-py3-none-any.whl

Download URL gdriveaudio-0.1.15-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27e8eacfbd51f9c16fce3c1bf1bce2963ab6baf1fa26b44b8460746ac69ab905
BLAKE2b-256 checksum
How to use checksums
f73c1976063c3fb313fb42429c1a28fe659572a6ca6d77e4c34c1c5cc83cbda9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page