changed indent style

This commit is contained in:
2021-09-22 15:32:52 -05:00
parent de28e80327
commit ab264d4100
39 changed files with 1871 additions and 1872 deletions

View File

@@ -10,168 +10,168 @@ from .import base
log = logging.getLogger("extractors.funkwhale")
class interface(base.baseInterface):
name = "Funkwhale"
enabled = config.app["services"]["funkwhale"].get("enabled")
# This should not be enabled if credentials are not in config.
if config.app["services"]["funkwhale"]["username"] == "" or config.app["services"]["funkwhale"]["password"] == "":
enabled = False
name = "Funkwhale"
enabled = config.app["services"]["funkwhale"].get("enabled")
# This should not be enabled if credentials are not in config.
if config.app["services"]["funkwhale"]["username"] == "" or config.app["services"]["funkwhale"]["password"] == "":
enabled = False
def __init__(self):
super(interface, self).__init__()
self.setup()
def __init__(self):
super(interface, self).__init__()
self.setup()
def setup(self):
endpoint = config.app["services"]["funkwhale"]["endpoint"]
username = config.app["services"]["funkwhale"]["username"]
password = config.app["services"]["funkwhale"]["password"]
self.session = session.Session(instance_endpoint=endpoint, username=username, password=password)
self.session.login()
self.api = self.session.get_api()
def setup(self):
endpoint = config.app["services"]["funkwhale"]["endpoint"]
username = config.app["services"]["funkwhale"]["username"]
password = config.app["services"]["funkwhale"]["password"]
self.session = session.Session(instance_endpoint=endpoint, username=username, password=password)
self.session.login()
self.api = self.session.get_api()
def get_file_format(self):
self.file_extension = "flac"
return self.file_extension
def get_file_format(self):
self.file_extension = "flac"
return self.file_extension
def transcoder_enabled(self):
return False
def transcoder_enabled(self):
return False
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
log.debug("Retrieving data from Tidal...")
fieldtypes = ["artist", "album", "playlist"]
field = "track"
for i in fieldtypes:
if text.startswith(i+"://"):
field = i
text = text.replace(i+"://", "")
log.debug("Searching for %s..." % (field))
search_response = self.session.search(value=text, field=field)
self.results = []
if field == "track":
data = search_response.tracks
elif field == "artist":
data = []
artist = search_response.artists[0].id
if config.app["services"]["tidal"]["include_albums"]:
albums = self.session.get_artist_albums(artist)
for album in albums:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
data.append(track)
if config.app["services"]["tidal"]["include_compilations"]:
compilations = self.session.get_artist_albums_other(artist)
for album in compilations:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
data.append(track)
if config.app["services"]["tidal"]["include_singles"]:
singles = self.session.get_artist_albums_ep_singles(artist)
for album in singles:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
track.single = True
data.append(track)
for search_result in data:
s = base.song(self)
if not hasattr(search_result, "single"):
s.title = "{0}. {1}".format(self.format_number(search_result.track_num), search_result.name)
else:
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
s.info = search_result
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
log.debug("Retrieving data from Tidal...")
fieldtypes = ["artist", "album", "playlist"]
field = "track"
for i in fieldtypes:
if text.startswith(i+"://"):
field = i
text = text.replace(i+"://", "")
log.debug("Searching for %s..." % (field))
search_response = self.session.search(value=text, field=field)
self.results = []
if field == "track":
data = search_response.tracks
elif field == "artist":
data = []
artist = search_response.artists[0].id
if config.app["services"]["tidal"]["include_albums"]:
albums = self.session.get_artist_albums(artist)
for album in albums:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
data.append(track)
if config.app["services"]["tidal"]["include_compilations"]:
compilations = self.session.get_artist_albums_other(artist)
for album in compilations:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
data.append(track)
if config.app["services"]["tidal"]["include_singles"]:
singles = self.session.get_artist_albums_ep_singles(artist)
for album in singles:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
track.single = True
data.append(track)
for search_result in data:
s = base.song(self)
if not hasattr(search_result, "single"):
s.title = "{0}. {1}".format(self.format_number(search_result.track_num), search_result.name)
else:
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
s.info = search_result
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def format_number(self, number):
if number < 10:
return "0%d" % (number)
else:
return number
def format_number(self, number):
if number < 10:
return "0%d" % (number)
else:
return number
def get_download_url(self, url):
url = self.session.get_media_url(url)
if url.startswith("https://") or url.startswith("http://") == False:
url = "rtmp://"+url
return url
def get_download_url(self, url):
url = self.session.get_media_url(url)
if url.startswith("https://") or url.startswith("http://") == False:
url = "rtmp://"+url
return url
def format_track(self, item):
return "{title}. {artist}. {duration}".format(title=item.title, duration=item.duration, artist=item.artist)
def format_track(self, item):
return "{title}. {artist}. {duration}".format(title=item.title, duration=item.duration, artist=item.artist)
class settings(base.baseSettings):
name = _("Tidal")
config_section = "tidal"
name = _("Tidal")
config_section = "tidal"
def get_quality_list(self):
results = dict(low=_("Low"), high=_("High"), lossless=_("Lossless"))
return results
def get_quality_list(self):
results = dict(low=_("Low"), high=_("High"), lossless=_("Lossless"))
return results
def get_quality_value(self, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if q.get(i) == self.quality.GetStringSelection():
return i
def get_quality_value(self, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if q.get(i) == self.quality.GetStringSelection():
return i
def set_quality_value(self, value, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if i == value:
self.quality.SetStringSelection(q.get(i))
break
def set_quality_value(self, value, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if i == value:
self.quality.SetStringSelection(q.get(i))
break
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
username = wx.StaticText(self, wx.NewId(), _("Tidal username or email address"))
self.username = wx.TextCtrl(self, wx.NewId())
usernamebox = wx.BoxSizer(wx.HORIZONTAL)
usernamebox.Add(username, 0, wx.ALL, 5)
usernamebox.Add(self.username, 0, wx.ALL, 5)
sizer.Add(usernamebox, 0, wx.ALL, 5)
self.map.append(("username", self.username))
password = wx.StaticText(self, wx.NewId(), _("Password"))
self.password = wx.TextCtrl(self, wx.NewId(), style=wx.TE_PASSWORD)
passwordbox = wx.BoxSizer(wx.HORIZONTAL)
passwordbox.Add(password, 0, wx.ALL, 5)
passwordbox.Add(self.password, 0, wx.ALL, 5)
sizer.Add(passwordbox, 0, wx.ALL, 5)
self.map.append(("password", self.password))
self.get_account = wx.Button(self, wx.NewId(), _("You can subscribe for a tidal account here"))
self.get_account.Bind(wx.EVT_BUTTON, self.on_get_account)
sizer.Add(self.get_account, 0, wx.ALL, 5)
quality = wx.StaticText(self, wx.NewId(), _("Audio quality"))
self.quality = wx.ComboBox(self, wx.NewId(), choices=[i for i in self.get_quality_list().values()], value=_("High"), style=wx.CB_READONLY)
qualitybox = wx.BoxSizer(wx.HORIZONTAL)
qualitybox.Add(quality, 0, wx.ALL, 5)
qualitybox.Add(self.quality, 0, wx.ALL, 5)
sizer.Add(qualitybox, 0, wx.ALL, 5)
# Monkeypatch for getting the right quality value here.
self.quality.GetValue = self.get_quality_value
self.quality.SetValue = self.set_quality_value
self.map.append(("quality", self.quality))
include = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Search by artist"))
self.include_albums = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include albums"))
self.include_compilations = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include compilations"))
self.include_singles = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include singles"))
sizer.Add(include, 0, wx.ALL, 5)
self.map.append(("include_albums", self.include_albums))
self.map.append(("include_compilations", self.include_compilations))
self.map.append(("include_singles", self.include_singles))
self.SetSizer(sizer)
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
username = wx.StaticText(self, wx.NewId(), _("Tidal username or email address"))
self.username = wx.TextCtrl(self, wx.NewId())
usernamebox = wx.BoxSizer(wx.HORIZONTAL)
usernamebox.Add(username, 0, wx.ALL, 5)
usernamebox.Add(self.username, 0, wx.ALL, 5)
sizer.Add(usernamebox, 0, wx.ALL, 5)
self.map.append(("username", self.username))
password = wx.StaticText(self, wx.NewId(), _("Password"))
self.password = wx.TextCtrl(self, wx.NewId(), style=wx.TE_PASSWORD)
passwordbox = wx.BoxSizer(wx.HORIZONTAL)
passwordbox.Add(password, 0, wx.ALL, 5)
passwordbox.Add(self.password, 0, wx.ALL, 5)
sizer.Add(passwordbox, 0, wx.ALL, 5)
self.map.append(("password", self.password))
self.get_account = wx.Button(self, wx.NewId(), _("You can subscribe for a tidal account here"))
self.get_account.Bind(wx.EVT_BUTTON, self.on_get_account)
sizer.Add(self.get_account, 0, wx.ALL, 5)
quality = wx.StaticText(self, wx.NewId(), _("Audio quality"))
self.quality = wx.ComboBox(self, wx.NewId(), choices=[i for i in self.get_quality_list().values()], value=_("High"), style=wx.CB_READONLY)
qualitybox = wx.BoxSizer(wx.HORIZONTAL)
qualitybox.Add(quality, 0, wx.ALL, 5)
qualitybox.Add(self.quality, 0, wx.ALL, 5)
sizer.Add(qualitybox, 0, wx.ALL, 5)
# Monkeypatch for getting the right quality value here.
self.quality.GetValue = self.get_quality_value
self.quality.SetValue = self.set_quality_value
self.map.append(("quality", self.quality))
include = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Search by artist"))
self.include_albums = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include albums"))
self.include_compilations = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include compilations"))
self.include_singles = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include singles"))
sizer.Add(include, 0, wx.ALL, 5)
self.map.append(("include_albums", self.include_albums))
self.map.append(("include_compilations", self.include_compilations))
self.map.append(("include_singles", self.include_singles))
self.SetSizer(sizer)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)
def on_get_account(self, *args, **kwargs):
webbrowser.open_new_tab("https://tidal.com")
def on_get_account(self, *args, **kwargs):
webbrowser.open_new_tab("https://tidal.com")

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from . import vk, youtube, zaycev, tidal
from . import vk, youtube, zaycev, tidal

View File

@@ -7,75 +7,75 @@ import config
log = logging.getLogger("extractors.config")
class baseInterface(object):
name = "base"
enabled = False
needs_transcode = False
results = []
name = "base"
enabled = False
needs_transcode = False
results = []
def __init__(self):
super(baseInterface, self).__init__()
log.debug("started extraction service for {0}".format(self.name,))
def __init__(self):
super(baseInterface, self).__init__()
log.debug("started extraction service for {0}".format(self.name,))
def search(self, text, *args, **kwargs):
raise NotImplementedError()
def search(self, text, *args, **kwargs):
raise NotImplementedError()
def get_download_url(self, url):
raise NotImplementedError()
def get_download_url(self, url):
raise NotImplementedError()
def format_track(self, item):
raise NotImplementedError()
def format_track(self, item):
raise NotImplementedError()
def get_file_format(self):
return "mp3"
def get_file_format(self):
return "mp3"
def transcoder_enabled(self):
return False
def transcoder_enabled(self):
return False
def get_metadata(self, item):
data = dict()
keys = ["title", "album", "artist", "tracknumber"]
for k in keys:
if hasattr(item, k):
data[k] = getattr(item, k)
return data
def get_metadata(self, item):
data = dict()
keys = ["title", "album", "artist", "tracknumber"]
for k in keys:
if hasattr(item, k):
data[k] = getattr(item, k)
return data
class song(object):
""" Represents a song in all services. Data will be filled by the service itself"""
""" Represents a song in all services. Data will be filled by the service itself"""
def __init__(self, extractor):
self.extractor = extractor
self.bitrate = 0
self.title = ""
self.artist = ""
self.duration = ""
self.size = 0
self.url = ""
self.download_url = ""
self.info = None
def __init__(self, extractor):
self.extractor = extractor
self.bitrate = 0
self.title = ""
self.artist = ""
self.duration = ""
self.size = 0
self.url = ""
self.download_url = ""
self.info = None
def format_track(self):
return self.extractor.format_track(self)
def format_track(self):
return self.extractor.format_track(self)
def get_download_url(self):
self.download_url = self.extractor.get_download_url(self.url)
def get_download_url(self):
self.download_url = self.extractor.get_download_url(self.url)
def get_metadata(self):
return self.extractor.get_metadata(self)
def get_metadata(self):
return self.extractor.get_metadata(self)
class baseSettings(wx.Panel):
config_section = "base"
config_section = "base"
def __init__(self, *args, **kwargs):
super(baseSettings, self).__init__(*args, **kwargs)
self.map = []
def __init__(self, *args, **kwargs):
super(baseSettings, self).__init__(*args, **kwargs)
self.map = []
def save(self):
for i in self.map:
config.app["services"][self.config_section][i[0]] = i[1].GetValue()
def save(self):
for i in self.map:
config.app["services"][self.config_section][i[0]] = i[1].GetValue()
def load(self):
for i in self.map:
if i[0] in config.app["services"][self.config_section]:
i[1].SetValue(config.app["services"][self.config_section][i[0]])
else:
log.error("No key available: {key} on extractor {extractor}".format(key=i[0], extractor=self.config_section))
def load(self):
for i in self.map:
if i[0] in config.app["services"][self.config_section]:
i[1].SetValue(config.app["services"][self.config_section][i[0]])
else:
log.error("No key available: {key} on extractor {extractor}".format(key=i[0], extractor=self.config_section))

View File

@@ -15,221 +15,221 @@ from .import base
log = logging.getLogger("services.tidal")
class interface(base.baseInterface):
name = "tidal"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["tidal"].get("enabled")
# This should not be enabled if credentials are not set in config.
if config.app["services"]["tidal"]["username"] == "" or config.app["services"]["tidal"]["password"] == "":
enabled = False
else:
enabled = False
name = "tidal"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["tidal"].get("enabled")
# This should not be enabled if credentials are not set in config.
if config.app["services"]["tidal"]["username"] == "" or config.app["services"]["tidal"]["password"] == "":
enabled = False
else:
enabled = False
def __init__(self):
super(interface, self).__init__()
self.setup()
def __init__(self):
super(interface, self).__init__()
self.setup()
def setup(self):
# Assign quality or switch to high if not specified/not found.
if hasattr(tidalapi.Quality, config.app["services"]["tidal"]["quality"]):
quality = getattr(tidalapi.Quality, config.app["services"]["tidal"]["quality"])
else:
quality = tidalapi.Quality.high
# We need to instantiate a config object to pass quality settings.
_config = tidalapi.Config(quality=quality)
username = config.app["services"]["tidal"]["username"]
password = config.app["services"]["tidal"]["password"]
log.debug("Using quality: %s" % (quality,))
self.session = tidalapi.Session(config=_config)
self.session.login(username=username, password=password)
def setup(self):
# Assign quality or switch to high if not specified/not found.
if hasattr(tidalapi.Quality, config.app["services"]["tidal"]["quality"]):
quality = getattr(tidalapi.Quality, config.app["services"]["tidal"]["quality"])
else:
quality = tidalapi.Quality.high
# We need to instantiate a config object to pass quality settings.
_config = tidalapi.Config(quality=quality)
username = config.app["services"]["tidal"]["username"]
password = config.app["services"]["tidal"]["password"]
log.debug("Using quality: %s" % (quality,))
self.session = tidalapi.Session(config=_config)
self.session.login(username=username, password=password)
def get_file_format(self):
""" Returns the file format (mp3 or flac) depending in quality set. """
if config.app["services"]["tidal"]["quality"] == "lossless":
self.file_extension = "flac"
elif config.app["services"]["tidal"]["avoid_transcoding"] == True:
self.file_extension = "m4a"
else:
self.file_extension = "mp3"
return self.file_extension
def get_file_format(self):
""" Returns the file format (mp3 or flac) depending in quality set. """
if config.app["services"]["tidal"]["quality"] == "lossless":
self.file_extension = "flac"
elif config.app["services"]["tidal"]["avoid_transcoding"] == True:
self.file_extension = "m4a"
else:
self.file_extension = "mp3"
return self.file_extension
def transcoder_enabled(self):
# If quality is set to high, tidal returns audio in AAC format at 256 KBPS. So we convert it with vlc to mp3 at 320KBPS.
# toDo: Shall this be a setting and allow MusicDL to spit out the m4a file directly?
if config.app["services"]["tidal"]["quality"] == "lossless":
return False
elif config.app["services"]["tidal"]["avoid_transcoding"]:
return False
else:
return True
def transcoder_enabled(self):
# If quality is set to high, tidal returns audio in AAC format at 256 KBPS. So we convert it with vlc to mp3 at 320KBPS.
# toDo: Shall this be a setting and allow MusicDL to spit out the m4a file directly?
if config.app["services"]["tidal"]["quality"] == "lossless":
return False
elif config.app["services"]["tidal"]["avoid_transcoding"]:
return False
else:
return True
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
log.debug("Retrieving data from Tidal...")
# Check for top:// protocol.
if text.startswith("top://"):
text = text.replace("top://", "")
return self.search_for_top(text)
fieldtypes = ["artist", "album", "playlist"]
field = "track"
for i in fieldtypes:
if text.startswith(i+"://"):
field = i
text = text.replace(i+"://", "")
log.debug("Searching for %s..." % (field))
search_response = self.session.search(value=text, field=field)
self.results = []
if field == "track":
data = search_response.tracks
elif field == "artist":
data = []
artist = search_response.artists[0].id
if config.app["services"]["tidal"]["include_albums"]:
albums = self.session.get_artist_albums(artist)
for album in albums:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
track.album = album
data.append(track)
if config.app["services"]["tidal"]["include_compilations"]:
compilations = self.session.get_artist_albums_other(artist)
for album in compilations:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
data.append(track)
if config.app["services"]["tidal"]["include_singles"]:
singles = self.session.get_artist_albums_ep_singles(artist)
for album in singles:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
# track.single = True
data.append(track)
for search_result in data:
s = base.song(self)
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
s.tracknumber = str(search_result.track_num)
s.album = search_result.album.name
if search_result.album.num_tracks == None:
s.single = True
s.info = search_result
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
log.debug("Retrieving data from Tidal...")
# Check for top:// protocol.
if text.startswith("top://"):
text = text.replace("top://", "")
return self.search_for_top(text)
fieldtypes = ["artist", "album", "playlist"]
field = "track"
for i in fieldtypes:
if text.startswith(i+"://"):
field = i
text = text.replace(i+"://", "")
log.debug("Searching for %s..." % (field))
search_response = self.session.search(value=text, field=field)
self.results = []
if field == "track":
data = search_response.tracks
elif field == "artist":
data = []
artist = search_response.artists[0].id
if config.app["services"]["tidal"]["include_albums"]:
albums = self.session.get_artist_albums(artist)
for album in albums:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
track.album = album
data.append(track)
if config.app["services"]["tidal"]["include_compilations"]:
compilations = self.session.get_artist_albums_other(artist)
for album in compilations:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
data.append(track)
if config.app["services"]["tidal"]["include_singles"]:
singles = self.session.get_artist_albums_ep_singles(artist)
for album in singles:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
# track.single = True
data.append(track)
for search_result in data:
s = base.song(self)
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
s.tracknumber = str(search_result.track_num)
s.album = search_result.album.name
if search_result.album.num_tracks == None:
s.single = True
s.info = search_result
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search_for_top(self, artist):
search_response = self.session.search(value=artist, field="artist")
self.results = []
artist = search_response.artists[0].id
results = self.session.get_artist_top_tracks(artist)
for search_result in results:
s = base.song(self)
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
s.tracknumber = str(search_result.track_num)
s.album = search_result.album.name
if search_result.album.num_tracks == None:
s.single = True
s.info = search_result
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search_for_top(self, artist):
search_response = self.session.search(value=artist, field="artist")
self.results = []
artist = search_response.artists[0].id
results = self.session.get_artist_top_tracks(artist)
for search_result in results:
s = base.song(self)
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
s.tracknumber = str(search_result.track_num)
s.album = search_result.album.name
if search_result.album.num_tracks == None:
s.single = True
s.info = search_result
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def format_number(self, number):
if number < 10:
return "0%d" % (number)
else:
return number
def format_number(self, number):
if number < 10:
return "0%d" % (number)
else:
return number
def get_download_url(self, url):
url = self.session.get_media_url(url)
if url.startswith("https://") or url.startswith("http://") == False:
url = "rtmp://"+url
return url
def get_download_url(self, url):
url = self.session.get_media_url(url)
if url.startswith("https://") or url.startswith("http://") == False:
url = "rtmp://"+url
return url
def format_track(self, item):
if not hasattr(item, "single"):
return "{0}. {1}".format(self.format_number(int(item.tracknumber)), item.title)
else:
return "{title}. {artist}. {duration}".format(title=item.title, duration=item.duration, artist=item.artist)
def format_track(self, item):
if not hasattr(item, "single"):
return "{0}. {1}".format(self.format_number(int(item.tracknumber)), item.title)
else:
return "{title}. {artist}. {duration}".format(title=item.title, duration=item.duration, artist=item.artist)
class settings(base.baseSettings):
name = _("Tidal")
config_section = "tidal"
name = _("Tidal")
config_section = "tidal"
def get_quality_list(self):
results = dict(low=_("Low"), high=_("High"), lossless=_("Lossless"))
return results
def get_quality_list(self):
results = dict(low=_("Low"), high=_("High"), lossless=_("Lossless"))
return results
def get_quality_value(self, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if q.get(i) == self.quality.GetStringSelection():
return i
def get_quality_value(self, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if q.get(i) == self.quality.GetStringSelection():
return i
def set_quality_value(self, value, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if i == value:
self.quality.SetStringSelection(q.get(i))
break
def set_quality_value(self, value, *args, **kwargs):
q = self.get_quality_list()
for i in q.keys():
if i == value:
self.quality.SetStringSelection(q.get(i))
break
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
self.avoid_transcoding = wx.CheckBox(self, wx.NewId(), _("Avoid transcoding when downloading"))
self.map.append(("avoid_transcoding", self.avoid_transcoding))
sizer.Add(self.avoid_transcoding, 0, wx.ALL, 5)
username = wx.StaticText(self, wx.NewId(), _("Tidal username or email address"))
self.username = wx.TextCtrl(self, wx.NewId())
usernamebox = wx.BoxSizer(wx.HORIZONTAL)
usernamebox.Add(username, 0, wx.ALL, 5)
usernamebox.Add(self.username, 0, wx.ALL, 5)
sizer.Add(usernamebox, 0, wx.ALL, 5)
self.map.append(("username", self.username))
password = wx.StaticText(self, wx.NewId(), _("Password"))
self.password = wx.TextCtrl(self, wx.NewId(), style=wx.TE_PASSWORD)
passwordbox = wx.BoxSizer(wx.HORIZONTAL)
passwordbox.Add(password, 0, wx.ALL, 5)
passwordbox.Add(self.password, 0, wx.ALL, 5)
sizer.Add(passwordbox, 0, wx.ALL, 5)
self.map.append(("password", self.password))
self.get_account = wx.Button(self, wx.NewId(), _("You can subscribe for a tidal account here"))
self.get_account.Bind(wx.EVT_BUTTON, self.on_get_account)
sizer.Add(self.get_account, 0, wx.ALL, 5)
quality = wx.StaticText(self, wx.NewId(), _("Audio quality"))
self.quality = wx.ComboBox(self, wx.NewId(), choices=[i for i in self.get_quality_list().values()], value=_("High"), style=wx.CB_READONLY)
qualitybox = wx.BoxSizer(wx.HORIZONTAL)
qualitybox.Add(quality, 0, wx.ALL, 5)
qualitybox.Add(self.quality, 0, wx.ALL, 5)
sizer.Add(qualitybox, 0, wx.ALL, 5)
# Monkeypatch for getting the right quality value here.
self.quality.GetValue = self.get_quality_value
self.quality.SetValue = self.set_quality_value
self.map.append(("quality", self.quality))
include = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Search by artist"))
self.include_albums = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include albums"))
self.include_compilations = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include compilations"))
self.include_singles = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include singles"))
sizer.Add(include, 0, wx.ALL, 5)
self.map.append(("include_albums", self.include_albums))
self.map.append(("include_compilations", self.include_compilations))
self.map.append(("include_singles", self.include_singles))
self.SetSizer(sizer)
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
self.avoid_transcoding = wx.CheckBox(self, wx.NewId(), _("Avoid transcoding when downloading"))
self.map.append(("avoid_transcoding", self.avoid_transcoding))
sizer.Add(self.avoid_transcoding, 0, wx.ALL, 5)
username = wx.StaticText(self, wx.NewId(), _("Tidal username or email address"))
self.username = wx.TextCtrl(self, wx.NewId())
usernamebox = wx.BoxSizer(wx.HORIZONTAL)
usernamebox.Add(username, 0, wx.ALL, 5)
usernamebox.Add(self.username, 0, wx.ALL, 5)
sizer.Add(usernamebox, 0, wx.ALL, 5)
self.map.append(("username", self.username))
password = wx.StaticText(self, wx.NewId(), _("Password"))
self.password = wx.TextCtrl(self, wx.NewId(), style=wx.TE_PASSWORD)
passwordbox = wx.BoxSizer(wx.HORIZONTAL)
passwordbox.Add(password, 0, wx.ALL, 5)
passwordbox.Add(self.password, 0, wx.ALL, 5)
sizer.Add(passwordbox, 0, wx.ALL, 5)
self.map.append(("password", self.password))
self.get_account = wx.Button(self, wx.NewId(), _("You can subscribe for a tidal account here"))
self.get_account.Bind(wx.EVT_BUTTON, self.on_get_account)
sizer.Add(self.get_account, 0, wx.ALL, 5)
quality = wx.StaticText(self, wx.NewId(), _("Audio quality"))
self.quality = wx.ComboBox(self, wx.NewId(), choices=[i for i in self.get_quality_list().values()], value=_("High"), style=wx.CB_READONLY)
qualitybox = wx.BoxSizer(wx.HORIZONTAL)
qualitybox.Add(quality, 0, wx.ALL, 5)
qualitybox.Add(self.quality, 0, wx.ALL, 5)
sizer.Add(qualitybox, 0, wx.ALL, 5)
# Monkeypatch for getting the right quality value here.
self.quality.GetValue = self.get_quality_value
self.quality.SetValue = self.set_quality_value
self.map.append(("quality", self.quality))
include = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Search by artist"))
self.include_albums = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include albums"))
self.include_compilations = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include compilations"))
self.include_singles = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include singles"))
sizer.Add(include, 0, wx.ALL, 5)
self.map.append(("include_albums", self.include_albums))
self.map.append(("include_compilations", self.include_compilations))
self.map.append(("include_singles", self.include_singles))
self.SetSizer(sizer)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)
def on_get_account(self, *args, **kwargs):
webbrowser.open_new_tab("https://tidal.com")
def on_get_account(self, *args, **kwargs):
webbrowser.open_new_tab("https://tidal.com")

View File

@@ -16,81 +16,81 @@ application_name = "music_dl"
access_token = "e2237f17af545a4ba0bf6cb0b1a662e6"
class interface(base.baseInterface):
""" Class downloader for VK audios. """
name = "vk"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["vk"].get("enabled")
else:
enabled = False
""" Class downloader for VK audios. """
name = "vk"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["vk"].get("enabled")
else:
enabled = False
#util functions.
def get_auth(self):
# Authentication object
self.auth=HTTPBasicAuth(application_name, access_token)
#util functions.
def get_auth(self):
# Authentication object
self.auth=HTTPBasicAuth(application_name, access_token)
def get(self, endpoint, *args, **kwargs):
response = requests.get(url+endpoint, auth=self.auth, *args, **kwargs)
return response
def get(self, endpoint, *args, **kwargs):
response = requests.get(url+endpoint, auth=self.auth, *args, **kwargs)
return response
def __init__(self):
super(interface, self).__init__()
self.get_auth()
def __init__(self):
super(interface, self).__init__()
self.get_auth()
def get_file_format(self):
# Only mp3 audio is supported in VK so return it without further checks.
return "mp3"
def get_file_format(self):
# Only mp3 audio is supported in VK so return it without further checks.
return "mp3"
def transcoder_enabled(self):
return False
def transcoder_enabled(self):
return False
def search(self, text):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
log.debug("Retrieving data from vk...")
self.results = []
results = self.get("/vk/search", params=dict(text=text, maxresults=config.app["services"]["vk"]["max_results"]))
if results.status_code != 200:
return
results = results.json()
for search_result in results:
s = base.song(self)
s.title = search_result["title"]
s.artist = search_result["artist"]
s.duration = seconds_to_string(search_result["duration"])
s.url = search_result["url"]
s.info = search_result
self.results.append(s)
def search(self, text):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
log.debug("Retrieving data from vk...")
self.results = []
results = self.get("/vk/search", params=dict(text=text, maxresults=config.app["services"]["vk"]["max_results"]))
if results.status_code != 200:
return
results = results.json()
for search_result in results:
s = base.song(self)
s.title = search_result["title"]
s.artist = search_result["artist"]
s.duration = seconds_to_string(search_result["duration"])
s.url = search_result["url"]
s.info = search_result
self.results.append(s)
def get_download_url(self, file_url):
return "{url}/vk/download/?url={url2}".format(url=url, url2=file_url)
def get_download_url(self, file_url):
return "{url}/vk/download/?url={url2}".format(url=url, url2=file_url)
def format_track(self, item):
return "{title}. {artist}. {duration}".format(title=item.title, duration=item.duration, artist=item.artist)
def format_track(self, item):
return "{title}. {artist}. {duration}".format(title=item.title, duration=item.duration, artist=item.artist)
class settings(base.baseSettings):
name = _("VK")
config_section = "vk"
name = _("VK")
config_section = "vk"
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
max_results_label = wx.StaticText(self, wx.NewId(), _("Max results per page"))
self.max_results = wx.SpinCtrl(self, wx.NewId())
self.max_results.SetRange(1, 300)
max_results_sizer = wx.BoxSizer(wx.HORIZONTAL)
max_results_sizer.Add(max_results_label, 0, wx.ALL, 5)
max_results_sizer.Add(self.max_results, 0, wx.ALL, 5)
self.map.append(("max_results", self.max_results))
self.SetSizer(sizer)
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
max_results_label = wx.StaticText(self, wx.NewId(), _("Max results per page"))
self.max_results = wx.SpinCtrl(self, wx.NewId())
self.max_results.SetRange(1, 300)
max_results_sizer = wx.BoxSizer(wx.HORIZONTAL)
max_results_sizer.Add(max_results_label, 0, wx.ALL, 5)
max_results_sizer.Add(self.max_results, 0, wx.ALL, 5)
self.map.append(("max_results", self.max_results))
self.SetSizer(sizer)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)

View File

@@ -9,126 +9,126 @@ from .import base
log = logging.getLogger("extractors.youtube.com")
class interface(base.baseInterface):
name = "YouTube"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["youtube"].get("enabled")
else:
enabled = False
name = "YouTube"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["youtube"].get("enabled")
else:
enabled = False
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
if text.startswith("https") or text.startswith("http"):
return self.search_from_url(text)
type = "video"
max_results = config.app["services"]["youtube"]["max_results"]
log.debug("Retrieving data from Youtube...")
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
search_param = "ytsearch{}:{}".format(max_results, text)
result = ydl.extract_info(search_param, download=False)
self.results = []
for search_result in result["entries"]:
s = base.song(self)
s.title = search_result["title"]
s.url = "https://www.youtube.com/watch?v="+search_result["id"]
s.duration = seconds_to_string(search_result["duration"])
if search_result.get("track") != None:
s.title = search_result["track"]
if search_result.get("album") != None:
s.album = search_result["album"]
if search_result.get("artist") != None:
s.artist = search_result["artist"]
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
if text.startswith("https") or text.startswith("http"):
return self.search_from_url(text)
type = "video"
max_results = config.app["services"]["youtube"]["max_results"]
log.debug("Retrieving data from Youtube...")
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
search_param = "ytsearch{}:{}".format(max_results, text)
result = ydl.extract_info(search_param, download=False)
self.results = []
for search_result in result["entries"]:
s = base.song(self)
s.title = search_result["title"]
s.url = "https://www.youtube.com/watch?v="+search_result["id"]
s.duration = seconds_to_string(search_result["duration"])
if search_result.get("track") != None:
s.title = search_result["track"]
if search_result.get("album") != None:
s.album = search_result["album"]
if search_result.get("artist") != None:
s.artist = search_result["artist"]
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search_from_url(self, url):
log.debug("Getting download URL for {0}".format(url,))
if "playlist?list=" in url:
return self.search_from_playlist(url)
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'prefer-free-formats': True, 'format': 'bestaudio', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
result = ydl.extract_info(url, download=False)
if 'entries' in result:
videos = result['entries']
else:
videos = [result]
for video in videos:
s = base.song(self)
s.title = video["title"]
s.url = video["webpage_url"] # Cannot use direct URL here cause Youtube URLS expire after a minute.
s.duration = seconds_to_string(video["duration"])
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search_from_url(self, url):
log.debug("Getting download URL for {0}".format(url,))
if "playlist?list=" in url:
return self.search_from_playlist(url)
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'prefer-free-formats': True, 'format': 'bestaudio', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
result = ydl.extract_info(url, download=False)
if 'entries' in result:
videos = result['entries']
else:
videos = [result]
for video in videos:
s = base.song(self)
s.title = video["title"]
s.url = video["webpage_url"] # Cannot use direct URL here cause Youtube URLS expire after a minute.
s.duration = seconds_to_string(video["duration"])
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search_from_playlist(self, url):
id = url.split("=")[1]
max_results = 50
log.debug("Retrieving data from Youtube...")
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
result = ydl.extract_info(url, download=False)
self.results = []
for search_result in result["entries"]:
s = base.song(self)
s.title = search_result["title"]
s.url = "https://www.youtube.com/watch?v="+search_result["id"]
s.duration = seconds_to_string(search_result["duration"])
if search_result.get("track") != None:
s.title = search_result["track"]
if search_result.get("album") != None:
s.album = search_result["album"]
if search_result.get("artist") != None:
s.artist = search_result["artist"]
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search_from_playlist(self, url):
id = url.split("=")[1]
max_results = 50
log.debug("Retrieving data from Youtube...")
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
result = ydl.extract_info(url, download=False)
self.results = []
for search_result in result["entries"]:
s = base.song(self)
s.title = search_result["title"]
s.url = "https://www.youtube.com/watch?v="+search_result["id"]
s.duration = seconds_to_string(search_result["duration"])
if search_result.get("track") != None:
s.title = search_result["track"]
if search_result.get("album") != None:
s.album = search_result["album"]
if search_result.get("artist") != None:
s.artist = search_result["artist"]
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def get_download_url(self, url):
log.debug("Getting download URL for {0}".format(url,))
ydl = youtube_dl.YoutubeDL({'quiet': True, 'no_warnings': True, 'logger': log, 'prefer_insecure': True, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
result = ydl.extract_info(url, download=False)
if 'entries' in result:
video = result['entries'][0]
else:
video = result
# From here we should extract the first format so it will contain audio only.
log.debug("Download URL: {0}".format(video["formats"][0]["url"],))
return video["formats"][0]["url"]
def get_download_url(self, url):
log.debug("Getting download URL for {0}".format(url,))
ydl = youtube_dl.YoutubeDL({'quiet': True, 'no_warnings': True, 'logger': log, 'prefer_insecure': True, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
with ydl:
result = ydl.extract_info(url, download=False)
if 'entries' in result:
video = result['entries'][0]
else:
video = result
# From here we should extract the first format so it will contain audio only.
log.debug("Download URL: {0}".format(video["formats"][0]["url"],))
return video["formats"][0]["url"]
def format_track(self, item):
return "{0} {1}".format(item.title, item.duration)
def format_track(self, item):
return "{0} {1}".format(item.title, item.duration)
def transcoder_enabled(self):
return config.app["services"]["youtube"]["transcode"]
def transcoder_enabled(self):
return config.app["services"]["youtube"]["transcode"]
class settings(base.baseSettings):
name = _("Youtube")
config_section = "youtube"
name = _("Youtube")
config_section = "youtube"
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
max_results_label = wx.StaticText(self, wx.NewId(), _("Max results per page"))
self.max_results = wx.SpinCtrl(self, wx.NewId())
self.max_results.SetRange(1, 50)
max_results_sizer = wx.BoxSizer(wx.HORIZONTAL)
max_results_sizer.Add(max_results_label, 0, wx.ALL, 5)
max_results_sizer.Add(self.max_results, 0, wx.ALL, 5)
self.map.append(("max_results", self.max_results))
# self.transcode = wx.CheckBox(self, wx.NewId(), _("Enable transcode when downloading"))
# self.map.append(("transcode", self.transcode))
# sizer.Add(self.transcode, 0, wx.ALL, 5)
self.SetSizer(sizer)
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service"))
self.enabled.Bind(wx.EVT_CHECKBOX, self.on_enabled)
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
max_results_label = wx.StaticText(self, wx.NewId(), _("Max results per page"))
self.max_results = wx.SpinCtrl(self, wx.NewId())
self.max_results.SetRange(1, 50)
max_results_sizer = wx.BoxSizer(wx.HORIZONTAL)
max_results_sizer.Add(max_results_label, 0, wx.ALL, 5)
max_results_sizer.Add(self.max_results, 0, wx.ALL, 5)
self.map.append(("max_results", self.max_results))
# self.transcode = wx.CheckBox(self, wx.NewId(), _("Enable transcode when downloading"))
# self.map.append(("transcode", self.transcode))
# sizer.Add(self.transcode, 0, wx.ALL, 5)
self.SetSizer(sizer)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)
def on_enabled(self, *args, **kwargs):
for i in self.map:
if i[1] != self.enabled:
if self.enabled.GetValue() == True:
i[1].Enable(True)
else:
i[1].Enable(False)

View File

@@ -12,53 +12,53 @@ from . import base
log = logging.getLogger("extractors.zaycev.net")
class interface(base.baseInterface):
name = "zaycev.net"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["zaycev"].get("enabled")
else:
enabled = False
name = "zaycev.net"
if config.app != None: # Workaround for cx_freeze 6.2 in python 3.7.
enabled = config.app["services"]["zaycev"].get("enabled")
else:
enabled = False
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
site = "http://zaycev.net/search.html?query_search=%s" % (text,)
log.debug("Retrieving data from {0}...".format(site,))
r = requests.get(site)
soup = BeautifulSoup(r.text, 'html.parser')
search_results = soup.find_all("div", {"class": "musicset-track__title track-geo__title"})
self.results = []
for i in search_results:
# The easiest method to get artist and song names is to fetch links. There are only two links per result here.
data = i.find_all("a")
# from here, data[0] contains artist info and data[1] contains info of the retrieved song.
s = base.song(self)
s.title = data[1].text
s.artist = data[0].text
s.url = "http://zaycev.net%s" % (data[1].attrs["href"])
# s.duration = self.hd[i]["duration"]
# s.size = self.hd[i]["size"]
# s.bitrate = self.hd[i]["bitrate"]
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def search(self, text, page=1):
if text == "" or text == None:
raise ValueError("Text must be passed and should not be blank.")
site = "http://zaycev.net/search.html?query_search=%s" % (text,)
log.debug("Retrieving data from {0}...".format(site,))
r = requests.get(site)
soup = BeautifulSoup(r.text, 'html.parser')
search_results = soup.find_all("div", {"class": "musicset-track__title track-geo__title"})
self.results = []
for i in search_results:
# The easiest method to get artist and song names is to fetch links. There are only two links per result here.
data = i.find_all("a")
# from here, data[0] contains artist info and data[1] contains info of the retrieved song.
s = base.song(self)
s.title = data[1].text
s.artist = data[0].text
s.url = "http://zaycev.net%s" % (data[1].attrs["href"])
# s.duration = self.hd[i]["duration"]
# s.size = self.hd[i]["size"]
# s.bitrate = self.hd[i]["bitrate"]
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def get_download_url(self, url):
log.debug("Getting download URL for {0}".format(url,))
soups = BeautifulSoup(requests.get(url).text, 'html.parser')
data = json.loads(requests.get('http://zaycev.net' + soups.find('div', {'class':"musicset-track"}).get('data-url')).text)
log.debug("Download URL: {0}".format(data["url"]))
return data["url"]
def get_download_url(self, url):
log.debug("Getting download URL for {0}".format(url,))
soups = BeautifulSoup(requests.get(url).text, 'html.parser')
data = json.loads(requests.get('http://zaycev.net' + soups.find('div', {'class':"musicset-track"}).get('data-url')).text)
log.debug("Download URL: {0}".format(data["url"]))
return data["url"]
def format_track(self, item):
return "{0}. {1}. {2}".format(item.title, item.duration, item.size)
def format_track(self, item):
return "{0}. {1}. {2}".format(item.title, item.duration, item.size)
class settings(base.baseSettings):
name = _("zaycev.net")
config_section = "zaycev"
name = _("zaycev.net")
config_section = "zaycev"
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service (works only in the Russian Federation)"))
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
self.SetSizer(sizer)
def __init__(self, parent):
super(settings, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.enabled = wx.CheckBox(self, wx.NewId(), _("Enable this service (works only in the Russian Federation)"))
self.map.append(("enabled", self.enabled))
sizer.Add(self.enabled, 0, wx.ALL, 5)
self.SetSizer(sizer)