Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Updated to match new version of the library.
  • Loading branch information
umbrae committed Nov 22, 2011
commit 8d93b5b7fc73db5b6931d6abf3c8fd19c53962f3
17 changes: 2 additions & 15 deletions embedly/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,12 @@ def get_services(self):

return self.services

def service_matcher(self):
"""
Generate a really big regular expression that we can use to determine if a URL is serviced by embedly or not.
Returns a compiled regular expression.
"""
if self.service_re is not None:
return self.service_re

services = self.get_services()
service_expressions = list(itertools.chain.from_iterable([service['regex'] for service in services]))
self.service_re = re.compile('|'.join(service_expressions), re.I)

return self.service_re

def url_is_serviced(self, url):
"""
If a URL is serviced by Embed.ly, return True. Otherwise return False.
"""
return self.service_matcher().match(url) is not None
services = self.get_services()
return self._regex.match(url) is not None

@property
def regex(self):
Expand Down