MetadataXML.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from bs4 import BeautifulSoup
  2. from os import walk, listdir
  3. import re
  4. class MetadataXML:
  5. files_metadata = []
  6. list_information_metadata = []
  7. def __init__(self, path_directory_with_video):
  8. self.path_directory_with_video = path_directory_with_video
  9. self.create_list_files_metadata()
  10. self.create_list_information_metadata_file()
  11. def create_list_files_metadata(self):
  12. for root, _, files in walk(self.path_directory_with_video):
  13. self.files_metadata += [root + '/' + file for file in files if 'metadata' in file]
  14. def create_list_dir_raw(self):
  15. for dirs in listdir(F"{self.path_directory_with_video}recording/raw/"):
  16. self.list_raw.append(dirs)
  17. def get_list_files_metadata(self) -> list:
  18. return self.files_metadata
  19. class InformationMetaData:
  20. pass
  21. def create_list_information_metadata_file(self):
  22. for file in self.files_metadata:
  23. bs_data = BeautifulSoup(open(file), 'xml')
  24. server_origin = bs_data.find_all("bbb-origin-server-name")[0].get_text()
  25. information_metadata = self.InformationMetaData()
  26. information_metadata.id = bs_data.find_all("id")[0].get_text()
  27. information_metadata.server_name = server_origin
  28. information_metadata.root = "/".join(file.split("/")[0:-1]).replace(self.path_directory_with_video, "")
  29. self.list_information_metadata.append(information_metadata)
  30. if __name__ == "__main__":
  31. metadata_xml = MetadataXML("/home/alex/bigbluebutton/")
  32. metadata_xml.create_list_information_metadata_file()