Advertisement
Guest User

bitchute.lua for VLC

a guest
Dec 20th, 2020
23,745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.81 KB | None | 0 0
  1. --[[
  2.     bitchute.lua - VLC bitchute.com video stream plugin
  3.     Version 1.0.0
  4.     This playlist extension allows VLC to play bitchute.com videos
  5.  
  6.     It translates a bitchute.com webpage url to a VLC playlist entry
  7.     containing relevant metadata and the direct mp4 video url extracted from the webpage.
  8.  
  9.     copy this LUA script to your VLC lua playlist scripts folder.
  10.     Path is usually ...\VLC\lua\playlist\bitchute.lua
  11. --]]
  12.  
  13. -- Probe function.
  14. function probe()
  15.     return (vlc.access == "http" or vlc.access == "https")
  16.     and (string.match(vlc.path, "^www.bitchute%.com/video"))
  17. end
  18.  
  19. -- Parse function.
  20. function parse()
  21.     vlc.msg.info("Using BitChute Parse plugin")
  22.     local path, url, name, description, arturl, artist, canonicalURL
  23.  
  24.     while true do
  25.         line = vlc.readline()
  26.         if not line then break end
  27.  
  28.         -- source webpage url
  29.         if string.match( line, "<link id=\"canonical\"%s.+href=\"(.+)\"" ) then
  30.             _,_,canonicalURL = string.find( line, "<link id=\"canonical\"%s.+href=\"(.+)\"" )
  31.  
  32.         -- Title of the entry
  33.         elseif string.match( line, "<meta property=\"og:title\"" ) then                
  34.             _,_,name = string.find( line, "<meta property=\"og:title\" content=\"(.-)\"" )
  35.             name = vlc.strings.resolve_xml_special_chars( name )
  36.  
  37.         -- still image for artwork
  38.         elseif string.match( line, "<meta name=\"twitter:image:src\"" ) then       
  39.             arturl = string.match( line, "<meta name=\"twitter:image:src\" content=\"(.-)\"" )
  40.  
  41.         -- Artist for the entry
  42.         elseif string.match( line, "<p class=\"owner\"><a href=\"" ) then              
  43.             artist = string.match( line, "<p class=\"owner\"><a href=\".-\">(.-)</a>" )
  44.  
  45.         -- mp4 video url to play
  46.         elseif string.match( line, "<source src=\"(.+)%.mp4\"" ) then                      
  47.             _,_,url = string.find( line, "<source src=\"(.+%.mp4)\"" )
  48.  
  49.         -- Comments get description.
  50.         elseif string.match( line, "<meta name=\"description\"" ) then                 
  51.             _,_,description = string.find( line, "<meta name=\"description\"%s-content=\"(.+)" )
  52.             if (description ~= nil) then
  53.                 description = vlc.strings.resolve_xml_special_chars( description )
  54.             end
  55.  
  56.         end
  57.     end
  58.     description = description.."\n"..canonicalURL  -- add origin webpage url as new line in Comments
  59.     path = url
  60.     return { { path = path, name = name, description = description, arturl = arturl, artist = artist } }
  61. end
  62.  
  63. --[[
  64.   The playlist is a table of playlist items.
  65.   A playlist item has the following members:
  66.       .path: the item's full path / URL
  67.       .name: the item's name in playlist (OPTIONAL)
  68.       .title: the item's Title (OPTIONAL, meta data)
  69.       .artist: the item's Artist (OPTIONAL, meta data)
  70.       .genre: the item's Genre (OPTIONAL, meta data)
  71.       .copyright: the item's Copyright (OPTIONAL, meta data)
  72.       .album: the item's Album (OPTIONAL, meta data)
  73.       .tracknum: the item's Tracknum (OPTIONAL, meta data)
  74.       .description: the item's Description (OPTIONAL, meta data)
  75.       .rating: the item's Rating (OPTIONAL, meta data)
  76.       .date: the item's Date (OPTIONAL, meta data)
  77.       .setting: the item's Setting (OPTIONAL, meta data)
  78.       .url: the item's URL (OPTIONAL, meta data)
  79.       .language: the item's Language (OPTIONAL, meta data)
  80.       .nowplaying: the item's NowPlaying (OPTIONAL, meta data)
  81.       .publisher: the item's Publisher (OPTIONAL, meta data)
  82.       .encodedby: the item's EncodedBy (OPTIONAL, meta data)
  83.       .arturl: the item's ArtURL (OPTIONAL, meta data)
  84.       .trackid: the item's TrackID (OPTIONAL, meta data)
  85.       .options: a list of VLC options (OPTIONAL)
  86.                 example: .options = { "run-time=60" }
  87.       .duration: stream duration in seconds (OPTIONAL)
  88.       .meta: custom meta data (OPTIONAL, meta data)
  89.              A .meta field is a table of custom meta key value pairs.
  90.              example: .meta = { ["GVP docid"] = "-5784010886294950089", ["GVP version] = "1.1", Hello = "World!" }
  91. --]]
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement