-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from JVT038/Develop
Added Genius support with some small bug fixes and such
- Loading branch information
Showing
23 changed files
with
1,175 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
################################# | ||
#####How to use this script:##### | ||
#1. python fixartists.py######### | ||
#2. Enter directory in CLI####### | ||
#3. Let it run################### | ||
################################# | ||
from mutagen.easyid3 import EasyID3 | ||
from mutagen.flac import FLAC | ||
from mutagen.oggopus import OggOpus | ||
from mutagen.oggvorbis import OggVorbis | ||
import os | ||
directory = input('Enter relative or absolute path to audio files: ') | ||
files = os.listdir(directory) | ||
for file in files: | ||
extensions = ['MP3', 'OPUS', 'FLAC', 'OGG'] | ||
filepath = os.path.join(directory, file) | ||
extension = filepath.split('.')[len(filepath.split('.')) - 1].upper() | ||
if os.path.isfile(filepath): | ||
if extension.upper() in extensions: | ||
if extension == 'MP3': | ||
audio = EasyID3(filepath) | ||
elif extension == 'OPUS': | ||
audio = OggOpus(filepath) | ||
elif extension == 'FLAC': | ||
audio = FLAC(filepath) | ||
elif extension == 'OGG': | ||
audio = OggVorbis(filepath) | ||
if 'artist' in audio: | ||
old_artists = audio["artist"] | ||
if len(old_artists) == 1 and '; ' in old_artists[0]: | ||
new_artists = old_artists[0].split('; ') | ||
audio["artist"] = new_artists | ||
audio.save() | ||
print(f'Fixed artists of {file}') | ||
else: | ||
print(f'{file} already has the correct artist format, skipping...') | ||
else: | ||
print(f'{file} contains no TPE1 tag, skipping') | ||
else: | ||
print(f'{file} has an unsupported extension, skipping') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from lyricsgenius import Genius as geniusobj | ||
from metatube import logger, sockets | ||
class Genius(): | ||
def __init__(self, client_id): | ||
try: | ||
self.genius = geniusobj(client_id) | ||
except TypeError() as e: | ||
logger.error('Genius API failed: %s', str(e)) | ||
|
||
def search(self, data): | ||
search = self.genius.search_songs(data["title"], data["max"]) | ||
sockets.geniussearch(search) | ||
logger.info('Searched Genius for track \'%s\' ', data["title"]) | ||
|
||
def searchsong(data, token): | ||
genius = Genius(token) | ||
genius.search(data) | ||
|
||
def fetchsong(self, id): | ||
return self.genius.song(id) | ||
|
||
def fetchlyrics(self, url): | ||
return self.genius.lyrics(url) | ||
|
||
def fetchalbum(self, id): | ||
sockets.foundgeniusalbum(self.genius.album_tracks(id)) |
Oops, something went wrong.