@@ -72,35 +72,12 @@ class PyDvdCss:
72
72
if LIB :
73
73
break
74
74
if not LIB :
75
- err = "PyDvdCss: Unable to locate libdvdcss library, please install it.\n "
76
- if platform .system () == "Windows" :
77
- dll = f"https://github.com/allienx/libdvdcss-dll/raw/master/1.4.2/{ platform .architecture ()[0 ].replace ('b' , '-b' )} /libdvdcss-2.dll"
78
- err += "\n " .join ([
79
- "On Windows, the installation process is a bit annoying, so I calculated it all for you:" ,
80
- f"Download the following file: `{ dll } ``" ,
81
- f"Place the file in: `C:/Windows/{ 'SysWOW64' if platform .machine ().endswith ('64' ) else 'System32' } ``" ,
82
- f"Done!"
83
- ])
84
- elif platform .system () == "Darwin" :
85
- err += "\n " .join ([
86
- "On Mac, the installation process is easiest when using `brew`." ,
87
- "If you don't have brew installed, follow the instructions at `https://brew.sh`" ,
88
- "Once installed, open terminal and type: `brew install libdvdcss`" ,
89
- "Done!"
90
- ])
91
- elif platform .system () == "Linux" :
92
- err += "\n " .join ([
93
- "On Linux, the installation process is very simple." ,
94
- "Just check your Package Distro for `libdvdcss` or possibly `libdvdcss-2` or the alike." ,
95
- "If it's not found, check it's User Repository or compile it yourself." ,
96
- "If you compile it yourself, make sure it's somewhere in PATH for pydvdcss to find it." ,
97
- "pydvdcss uses ctypes.util.find_library to search for the library." ,
98
- "It uses `/sbin/ldconfig`, `gcc`, `objdump` and `ld` to try find the library." ,
99
- "Good luck!"
100
- ])
101
- raise EnvironmentError (err )
102
- LIB = ctypes .CDLL (LIB )
103
- # todo ; it's assuming find_library and cdll were successful
75
+ _libdvdcss_installation ()
76
+ try :
77
+ LIB = ctypes .CDLL (LIB )
78
+ except OSError :
79
+ _libdvdcss_installation ()
80
+
104
81
_open = ctypes .CFUNCTYPE (ctypes .c_long , ctypes .c_char_p )(("dvdcss_open" , LIB ))
105
82
_close = ctypes .CFUNCTYPE (ctypes .c_int , ctypes .c_long )(("dvdcss_close" , LIB ))
106
83
_seek = ctypes .CFUNCTYPE (ctypes .c_int , ctypes .c_long , ctypes .c_int , ctypes .c_int )(
@@ -133,6 +110,35 @@ def dispose(self):
133
110
# reset verbosity and cracking mode environment variables
134
111
self .set_verbosity (None )
135
112
self .set_cracking_mode (None )
113
+
114
+ def _libdvdcss_installation (self ):
115
+ err = "PyDvdCss: Unable to locate libdvdcss library, please install it.\n "
116
+ if platform .system () == "Windows" :
117
+ dll = f"https://github.com/allienx/libdvdcss-dll/raw/master/1.4.2/{ platform .architecture ()[0 ].replace ('b' , '-b' )} /libdvdcss-2.dll"
118
+ err += "\n " .join ([
119
+ "On Windows, the installation process is a bit annoying, so I calculated it all for you:" ,
120
+ f"Download the following file: `{ dll } ``" ,
121
+ f"Place the file in: `C:/Windows/{ 'SysWOW64' if platform .machine ().endswith ('64' ) else 'System32' } ``" ,
122
+ f"Done!"
123
+ ])
124
+ elif platform .system () == "Darwin" :
125
+ err += "\n " .join ([
126
+ "On Mac, the installation process is easiest when using `brew`." ,
127
+ "If you don't have brew installed, follow the instructions at `https://brew.sh`" ,
128
+ "Once installed, open terminal and type: `brew install libdvdcss`" ,
129
+ "Done!"
130
+ ])
131
+ elif platform .system () == "Linux" :
132
+ err += "\n " .join ([
133
+ "On Linux, the installation process is very simple." ,
134
+ "Just check your Package Distro for `libdvdcss` or possibly `libdvdcss-2` or the alike." ,
135
+ "If it's not found, check it's User Repository or compile it yourself." ,
136
+ "If you compile it yourself, make sure it's somewhere in PATH for pydvdcss to find it." ,
137
+ "pydvdcss uses ctypes.util.find_library to search for the library." ,
138
+ "It uses `/sbin/ldconfig`, `gcc`, `objdump` and `ld` to try find the library." ,
139
+ "Good luck!"
140
+ ])
141
+ raise EnvironmentError (err )
136
142
137
143
def open (self , psz_target ):
138
144
"""
0 commit comments