Merge pull request #286 from pauliyobo/next-gen

audio_services should now be completely independent  from the source …
This commit is contained in:
José Manuel 2019-03-15 19:14:56 +01:00 committed by GitHub
commit 7f86da1123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 17 deletions

View File

@ -1,8 +1,8 @@
from audio_services import matches_url from audio_services import matches_url
import json
import re
import urllib
import youtube_utils import youtube_utils
import requests
@matches_url('https://audioboom.com') @matches_url('https://audioboom.com')
def convert_audioboom(url): def convert_audioboom(url):
@ -14,16 +14,14 @@ def convert_audioboom(url):
@matches_url ('https://soundcloud.com/') @matches_url ('https://soundcloud.com/')
def convert_soundcloud (url): def convert_soundcloud (url):
client_id = "df8113ca95c157b6c9731f54b105b473" client_id = "df8113ca95c157b6c9731f54b105b473"
permalink = urllib.urlopen ('http://api.soundcloud.com/resolve.json?client_id=%s&url=%s' %(client_id, url)) with requests.get('http://api.soundcloud.com/resolve.json', client_id=client_id, url=url) as permalink:
if permalink.getcode () == 404: if permalink.status_code==404:
permalink.close () raise TypeError('%r is not a valid URL' % permalink.url)
raise TypeError('%r is not a valid URL' % url) else:
else: resolved_url = permalink.url
resolved_url = permalink.geturl () with requests.get(resolved_url) as track_url:
permalink.close () track_data = track_url.json()
track_url = urllib.urlopen (resolved_url)
track_data = json.loads (track_url.read ())
track_url.close ()
if track_data ['streamable']: if track_data ['streamable']:
return track_data ['stream_url'] + "?client_id=%s" %client_id return track_data ['stream_url'] + "?client_id=%s" %client_id
else: else:

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import time import time
import platform import platform
if platform.system() == "Windows": if platform.system() == "Windows":
@ -17,7 +17,7 @@ import config
import sound import sound
import languageHandler import languageHandler
import logging import logging
import youtube_utils from audio_services import youtube_utils
from controller.buffers import baseBuffers from controller.buffers import baseBuffers
from sessions.twitter import compose, utils from sessions.twitter import compose, utils
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded

View File

@ -4,7 +4,7 @@ import platform
system = platform.system() system = platform.system()
import application import application
import requests import requests
import youtube_utils from audio_services import youtube_utils
import arrow import arrow
if system == "Windows": if system == "Windows":
from update import updater from update import updater

BIN
src/snapshot.zip Normal file

Binary file not shown.

View File

@ -11,7 +11,7 @@ import audio_services
import paths import paths
import sound_lib import sound_lib
import output import output
import youtube_utils from audio_services import youtube_utils
import application import application
system = platform.system() system = platform.system()
if system=="Windows" and not hasattr(sys, 'frozen'): # We are running from source on Windows if system=="Windows" and not hasattr(sys, 'frozen'): # We are running from source on Windows