lua: http: add medialibrary endpoints
Merge request reports
Activity
Filter activity
added MRStatus::Reviewable label
added Component::Interface: HTTP server Type::feature labels
added MRStatus::InReview label and removed MRStatus::Reviewable label
mentioned in merge request Aymeriic/vlc!9
added 27 commits
-
fe111dc9...957c2d6a - 26 commits from branch
videolan:master
- bbe1fa9a - lua: http: add medialibrary endpoints
-
fe111dc9...957c2d6a - 26 commits from branch
mentioned in merge request Aymeriic/vlc!10
changed milestone to %4.0
added MRStatus::Stale label and removed MRStatus::InReview label
added MRStatus::InReview label and removed MRStatus::Stale label
- share/lua/intf/modules/medialib.lua 0 → 100644
123 end 124 125 local function get_genre_artists(get) 126 local genreId = get['genreId'] 127 if not genreId then 128 return wrap_result(400, "Missing genreId" ) 129 end 130 local artists = vlc.ml.genre_artists(genreId, get) 131 return wrap_result(200, artists) 132 end 133 134 local function wrap_thumbnail(thumbMrl) 135 if not thumbMrl then 136 return wrap_result(404, "Thumbnail not found") 137 end 138 filename = vlc.strings.make_path(thumbMrl) - share/lua/intf/modules/medialib.lua 0 → 100644
129 end 130 local artists = vlc.ml.genre_artists(genreId, get) 131 return wrap_result(200, artists) 132 end 133 134 local function wrap_thumbnail(thumbMrl) 135 if not thumbMrl then 136 return wrap_result(404, "Thumbnail not found") 137 end 138 filename = vlc.strings.make_path(thumbMrl) 139 local windowsdrive = string.match(filename, "^/%a:/.+$") --match windows drive letter 140 if windowsdrive then 141 filename = string.sub(filename, 2) --remove starting forward slash before the drive letter 142 end 143 local size = vlc.net.stat(filename).size 144 local ext = string.match(filename,"%.([^%.]-)$") - share/lua/intf/modules/medialib.lua 0 → 100644
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 19 --]==========================================================================] 20 21 local medialib = {} 22 local dkjson = require ("dkjson") 23 24 local function wrap_result(code, content, mime) 25 -- Automatically encode the content in json when the request didn't fail 26 -- and when no mime is provided 27 if code >= 200 and code < 300 and not mime then 28 content = dkjson.encode (content, { indent = true }) - share/lua/intf/modules/medialib.lua 0 → 100644
20 21 local medialib = {} 22 local dkjson = require ("dkjson") 23 24 local function wrap_result(code, content, mime) 25 -- Automatically encode the content in json when the request didn't fail 26 -- and when no mime is provided 27 if code >= 200 and code < 300 and not mime then 28 content = dkjson.encode (content, { indent = true }) 29 end 30 if not mime then 31 mime = "text/plain" 32 end 33 local res= "Status: " .. tostring(code) .. "\r\n" .. 34 "Content-Type: " .. mime .. "\r\n" .. 35 "Content-Length: " .. #content .. added MRStatus::Stale label and removed MRStatus::InReview label
- share/lua/intf/modules/medialib.lua 0 → 100644
10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 19 --]==========================================================================] 20 21 local medialib = {} 22 local dkjson = require ("dkjson") 23 24 local function wrap_result(code, content, mime) 25 -- Automatically encode the content in json when the request didn't fail That looks like a convenience kludge, of the kind that tends to fail in corner cases. AFAICT, the code should know when it needs JSON wrapping - not second-guess its own self.
Edited by Rémi Denis-Courmont