SHARE
TWEET

get video sources from /sys/class/video4linux/

DeaD_EyE Jun 27th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from pathlib import Path
  2.  
  3.  
  4. def get_video():
  5.     result = []
  6.     path = Path('/sys/class/video4linux/')
  7.     for video in path.glob('video*'):
  8.         index = int((video / 'index').read_text())
  9.         name = (video / 'name').read_text().strip()
  10.         result.append((index, name))
  11.     return sorted(result)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top