[freesound] Minor improvements
This commit is contained in:
parent
66400c470c
commit
67de24e449
@ -20,7 +20,7 @@ from .eighttracks import EightTracksIE
|
|||||||
from .escapist import EscapistIE
|
from .escapist import EscapistIE
|
||||||
from .facebook import FacebookIE
|
from .facebook import FacebookIE
|
||||||
from .flickr import FlickrIE
|
from .flickr import FlickrIE
|
||||||
from .freesound import FreeSoundIE
|
from .freesound import FreesoundIE
|
||||||
from .funnyordie import FunnyOrDieIE
|
from .funnyordie import FunnyOrDieIE
|
||||||
from .gamespot import GameSpotIE
|
from .gamespot import GameSpotIE
|
||||||
from .gametrailers import GametrailersIE
|
from .gametrailers import GametrailersIE
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import determine_ext
|
||||||
|
|
||||||
class FreeSoundIE(InfoExtractor):
|
class FreesoundIE(InfoExtractor):
|
||||||
_VALID_URL = r'(?:http://)?(?:www\.)?freesound\.org/people/([^/]+)/sounds/([^/]+)'
|
_VALID_URL = r'(?:https?://)?(?:www\.)?freesound\.org/people/([^/]+)/sounds/(?P<id>[^/]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.freesound.org/people/miklovan/sounds/194503/',
|
u'url': u'http://www.freesound.org/people/miklovan/sounds/194503/',
|
||||||
u'file': u'194503.mp3',
|
u'file': u'194503.mp3',
|
||||||
u'md5': u'12280ceb42c81f19a515c745eae07650',
|
u'md5': u'12280ceb42c81f19a515c745eae07650',
|
||||||
u'info_dict': {
|
u'info_dict': {
|
||||||
u"title": u"gulls in the city.wav by miklovan",
|
u"title": u"gulls in the city.wav",
|
||||||
u"uploader" : u"miklovan"
|
u"uploader" : u"miklovan",
|
||||||
|
u'description': u'the sounds of seagulls in the city',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
music_id = mobj.group(2)
|
music_id = mobj.group('id')
|
||||||
webpage = self._download_webpage(url, music_id)
|
webpage = self._download_webpage(url, music_id)
|
||||||
title = self._html_search_regex(r'<meta property="og:title" content="([^"]*)"',
|
title = self._html_search_regex(r'<div id="single_sample_header">.*?<a href="#">(.+?)</a>',
|
||||||
webpage, 'music title')
|
webpage, 'music title', flags=re.DOTALL)
|
||||||
music_url = self._html_search_regex(r'<meta property="og:audio" content="([^"]*)"',
|
music_url = self._og_search_property('audio', webpage, 'music url')
|
||||||
webpage, 'music url')
|
description = self._html_search_regex(r'<div id="sound_description">(.*?)</div>',
|
||||||
uploader = self._html_search_regex(r'<meta property="og:audio:artist" content="([^"]*)"',
|
webpage, 'description', fatal=False, flags=re.DOTALL)
|
||||||
webpage, 'music uploader')
|
|
||||||
ext = music_url.split('.')[-1]
|
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
'id': music_id,
|
'id': music_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': music_url,
|
'url': music_url,
|
||||||
'uploader': uploader,
|
'uploader': self._og_search_property('audio:artist', webpage, 'music uploader'),
|
||||||
'ext': ext,
|
'ext': determine_ext(music_url),
|
||||||
}]
|
'description': description,
|
||||||
|
}]
|
||||||
|
Loading…
Reference in New Issue
Block a user