DeaD_EyE

get video sources from /sys/class/video4linux/

Jun 27th, 2019
95
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