Search plugin: use same port number that server is running on
This commit is contained in:
parent
93cbea380b
commit
2be1743133
@ -7,5 +7,5 @@
|
|||||||
<Url type="text/html" method="GET" template="http://localhost/youtube.com/search">
|
<Url type="text/html" method="GET" template="http://localhost/youtube.com/search">
|
||||||
<Param name="query" value="{searchTerms}"/>
|
<Param name="query" value="{searchTerms}"/>
|
||||||
</Url>
|
</Url>
|
||||||
<SearchForm>http://localhost/youtube.com/search</SearchForm>
|
<SearchForm>http://localhost:$port_number/youtube.com/search</SearchForm>
|
||||||
</SearchPlugin>
|
</SearchPlugin>
|
@ -1,9 +1,9 @@
|
|||||||
import mimetypes
|
import mimetypes
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from youtube import local_playlist, watch, search, playlist, channel, comments, common, account_functions
|
from youtube import local_playlist, watch, search, playlist, channel, comments, common, account_functions
|
||||||
|
import settings
|
||||||
YOUTUBE_FILES = (
|
YOUTUBE_FILES = (
|
||||||
"/shared.css",
|
"/shared.css",
|
||||||
"/opensearch.xml",
|
|
||||||
'/comments.css',
|
'/comments.css',
|
||||||
'/favicon.ico',
|
'/favicon.ico',
|
||||||
)
|
)
|
||||||
@ -47,14 +47,23 @@ def youtube(env, start_response):
|
|||||||
elif path.startswith("/playlists"):
|
elif path.startswith("/playlists"):
|
||||||
start_response('200 OK', (('Content-type','text/html'),) )
|
start_response('200 OK', (('Content-type','text/html'),) )
|
||||||
return local_playlist.get_playlist_page(path[10:], query_string=query_string).encode()
|
return local_playlist.get_playlist_page(path[10:], query_string=query_string).encode()
|
||||||
|
|
||||||
elif path.startswith("/api/"):
|
elif path.startswith("/api/"):
|
||||||
start_response('200 OK', () )
|
start_response('200 OK', () )
|
||||||
result = common.fetch_url('https://www.youtube.com' + path + ('?' + query_string if query_string else ''))
|
result = common.fetch_url('https://www.youtube.com' + path + ('?' + query_string if query_string else ''))
|
||||||
result = result.replace(b"align:start position:0%", b"")
|
result = result.replace(b"align:start position:0%", b"")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
elif path == "/post_comment":
|
elif path == "/post_comment":
|
||||||
start_response('200 OK', () )
|
start_response('200 OK', () )
|
||||||
return account_functions.get_post_comment_page(query_string).encode()
|
return account_functions.get_post_comment_page(query_string).encode()
|
||||||
|
|
||||||
|
elif path == "/opensearch.xml":
|
||||||
|
with open("youtube" + path, 'rb') as f:
|
||||||
|
mime_type = mimetypes.guess_type(path)[0] or 'application/octet-stream'
|
||||||
|
start_response('200 OK', (('Content-type',mime_type),) )
|
||||||
|
return f.read().replace(b'$port_number', str(settings.port_number).encode())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
start_response('404 Not Found', () )
|
start_response('404 Not Found', () )
|
||||||
return b'404 Not Found'
|
return b'404 Not Found'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user