Added VK extractor

This commit is contained in:
Manuel Cortez 2018-03-01 10:42:47 -06:00
parent 12a2378179
commit 741843b827
3 changed files with 32 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import utils
import application
from pubsub import pub
from wxUI import mainWindow, menus
from extractors import zaycev, youtube
from extractors import zaycev, youtube, vk
from update import updater
from . import player
@ -206,6 +206,8 @@ class Controller(object):
extractor = self.window.extractor.GetValue()
if extractor == "youtube":
self.extractor = youtube.interface()
elif extractor == "vk":
self.extractor = vk.interface()
elif extractor == "zaycev.net":
self.extractor = zaycev.interface()
elif extractor == "":

28
src/extractors/vk.py Normal file
View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
import requests
from .import baseFile
from update.utils import seconds_to_string
api_endpoint = "https://api-2.datmusic.xyz"
class interface(object):
def __init__(self):
self.results = []
self.name = "vk"
self.needs_transcode = False
def search(self, text, page=1):
self.results = []
search_results = requests.get("{0}/search?q={1}&page={2}".format(api_endpoint, text, page))
search_results = search_results.json()["data"]
for i in search_results:
s = baseFile.song(self)
s.title = i["title"]
# URRL is not needed here as download_url is already provided. So let's skip that part.
s.duration = seconds_to_string(i["duration"])
s.download_url = i["stream"]
self.results.append(s)
def get_download_url(self, url):
return None

View File

@ -39,7 +39,7 @@ class mainWindow(wx.Frame):
box.Add(lbl2, 0, wx.GROW)
box.Add(self.text, 1, wx.GROW)
box.Add(wx.StaticText(self.panel, wx.NewId(), _("Search in")), 0, wx.GROW)
self.extractor = wx.ComboBox(self.panel, wx.NewId(), choices=["youtube", "zaycev.net"], value="youtube", style=wx.CB_READONLY)
self.extractor = wx.ComboBox(self.panel, wx.NewId(), choices=["youtube", "vk", "zaycev.net"], value="youtube", style=wx.CB_READONLY)
box.Add(self.extractor, 1, wx.GROW)
self.search = wx.Button(self.panel, wx.NewId(), _("Search"))
self.search.SetDefault()