mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 07:28:39 +00:00
Use faster (non-regex) version of is_url.
This commit is contained in:
parent
4a7782af28
commit
50ae65b58a
2 changed files with 4 additions and 4 deletions
|
@ -354,7 +354,7 @@ def fdate(seconds):
|
||||||
|
|
||||||
def is_url(url):
|
def is_url(url):
|
||||||
"""
|
"""
|
||||||
A simple regex test to check if the URL is valid
|
A simple test to check if the URL is valid
|
||||||
|
|
||||||
:param url: the url to test
|
:param url: the url to test
|
||||||
:type url: string
|
:type url: string
|
||||||
|
@ -367,8 +367,7 @@ def is_url(url):
|
||||||
True
|
True
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import re
|
return url.partition('://')[0] in ("http", "https", "ftp", "udp")
|
||||||
return bool(re.search('^(https?|ftp|udp)://', url))
|
|
||||||
|
|
||||||
def is_magnet(uri):
|
def is_magnet(uri):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -48,6 +48,7 @@ from deluge.log import LOG as log
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
from deluge.common import is_url
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
from deluge.httpdownloader import download_file
|
from deluge.httpdownloader import download_file
|
||||||
from detect import detect_compression, detect_format, create_reader, UnknownFormatError
|
from detect import detect_compression, detect_format, create_reader, UnknownFormatError
|
||||||
|
@ -136,7 +137,7 @@ class Core(CorePluginBase):
|
||||||
self.up_to_date = False
|
self.up_to_date = False
|
||||||
if force:
|
if force:
|
||||||
self.reader = None
|
self.reader = None
|
||||||
self.is_url = self.config["url"].split("://")[0] in ("http", "https")
|
self.is_url = is_url(self.config["url"])
|
||||||
|
|
||||||
# Start callback chain
|
# Start callback chain
|
||||||
if self.is_url:
|
if self.is_url:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue