File tree Expand file tree Collapse file tree 4 files changed +53
-26
lines changed
Expand file tree Collapse file tree 4 files changed +53
-26
lines changed Original file line number Diff line number Diff line change 11"""Zero Configuration DLNA Server - A simple DLNA media server."""
2- import multiprocessing
3- multiprocessing .set_start_method ("fork" )
42import hashlib
53import os
64import socket
97from http .server import ThreadingHTTPServer
108import argparse
119
12- from constants import (
13- SERVER_NAME ,
14- SERVER_DESCRIPTION ,
15- SERVER_VERSION ,
16- SERVER_MANUFACTURER ,
17- is_supported_media_file ,
18- )
19- from dlna import DLNAHandler
20- from ssdp import SSDPServer
10+ try : # Hacky but needed to support both package and module imports
11+ from .constants import (
12+ SERVER_NAME ,
13+ SERVER_DESCRIPTION ,
14+ SERVER_VERSION ,
15+ SERVER_MANUFACTURER ,
16+ is_supported_media_file ,
17+ )
18+ from .dlna import DLNAHandler
19+ from .ssdp import SSDPServer
20+ except ImportError :
21+ from constants import (
22+ SERVER_NAME ,
23+ SERVER_DESCRIPTION ,
24+ SERVER_VERSION ,
25+ SERVER_MANUFACTURER ,
26+ is_supported_media_file ,
27+ )
28+ from dlna import DLNAHandler
29+ from ssdp import SSDPServer
2130
2231
2332class ZeroConfigDLNA :
Original file line number Diff line number Diff line change 66
77import os
88import socket
9- from custom_mimetypes import CustomMimeTypes
9+ try :
10+ from .custom_mimetypes import CustomMimeTypes
11+ except ImportError :
12+ from custom_mimetypes import CustomMimeTypes
1013
1114# Get hostname, truncate at first dot, then limit to 16 chars max
1215hostname = socket .gethostname ().split ("." )[0 ][:16 ]
Original file line number Diff line number Diff line change 44This module provides the HTTP request handler for a DLNA media server,
55implementing the necessary DLNA and UPnP protocols for media streaming.
66"""
7-
7+ import html
8+ import traceback
89import os
910import struct
1011import subprocess
1112import uuid
1213from http .server import BaseHTTPRequestHandler
1314from urllib .parse import unquote , urlparse , quote
14- import html
15- import traceback
16- from constants import (
17- SERVER_AGENT ,
18- SERVER_DESCRIPTION ,
19- SERVER_VERSION ,
20- SERVER_MANUFACTURER ,
21- is_supported_media_file ,
22- )
23- from custom_mimetypes import CustomMimeTypes
15+
16+ try :
17+ from .constants import (
18+ SERVER_AGENT ,
19+ SERVER_DESCRIPTION ,
20+ SERVER_VERSION ,
21+ SERVER_MANUFACTURER ,
22+ is_supported_media_file ,
23+ )
24+ from .custom_mimetypes import CustomMimeTypes
25+ except ImportError :
26+ from constants import (
27+ SERVER_AGENT ,
28+ SERVER_DESCRIPTION ,
29+ SERVER_VERSION ,
30+ SERVER_MANUFACTURER ,
31+ is_supported_media_file ,
32+ )
33+ from custom_mimetypes import CustomMimeTypes
2434
2535# Create a global instance of CustomMimeTypes
2636custom_mimetypes = CustomMimeTypes ()
Original file line number Diff line number Diff line change 1111import time
1212import struct
1313import select
14- from constants import (
15- SERVER_AGENT ,
16- )
14+ try :
15+ from .constants import (
16+ SERVER_AGENT ,
17+ )
18+ except ImportError :
19+ from constants import (
20+ SERVER_AGENT ,
21+ )
1722
1823
1924class SSDPServer :
You can’t perform that action at this time.
0 commit comments