Coverage for  / opt / hostedtoolcache / Python / 3.12.13 / x64 / lib / python3.12 / site-packages / fcp7xml_to_unreal / models / Audio.py: 98%

41 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-17 22:47 +0000

1from urllib.parse import unquote 

2 

3from fcp7xml_to_unreal import config, logger 

4from fcp7xml_to_unreal.models.helpers import frames_to_tc 

5 

6 

7class AudioFile: 

8 OUTPUT_VALS = [ 

9 "trackname", 

10 "filename", 

11 "starttime", 

12 "endtime", 

13 "shotlist", 

14 "trackcolor", 

15 "label", 

16 "effects", 

17 "path", 

18 ] 

19 

20 def __init__( 

21 self, 

22 filename, 

23 path, 

24 masterclipid, 

25 startFrame, 

26 endFrame, 

27 trackName=None, 

28 trackColor=None, 

29 ): 

30 self.trackname = trackName 

31 self.filename = filename 

32 self.path = unquote(path) 

33 self.masterclipid = masterclipid 

34 self.sf = int(startFrame) 

35 self.starttime = frames_to_tc(self.sf) 

36 self.ef = int(endFrame) 

37 self.endtime = frames_to_tc(self.ef) 

38 

39 self.trackcolor = trackColor 

40 self.printed = False 

41 self.effects = [] 

42 self.shotlist = [] 

43 

44 self.label = None 

45 

46 # 2025-12-22 macleodj-paramount simplify is_dialogue() check to label colors only 

47 if self.trackcolor.lower() in config["audio"]["track_colors"]: 

48 self.label = config["audio"]["track_colors"][self.trackcolor.lower()] 

49 else: 

50 self.label = config["audio"]["track_color_nomatch_label"] 

51 

52 # if _ef is -1, we can grab in and out, subtract in from out, add to sf to get ef 

53 

54 if (self.sf == -1) | (self.ef == -1): 

55 self.badTC = True 

56 else: 

57 self.badTC = False 

58 

59 logger.debug( 

60 f"Processing AudioFile entry for file reference named {self.filename}" 

61 ) 

62 

63 def is_music(self): 

64 return self.trackname.startswith(config["audio"]["music_track_prefix"]) 

65 

66 def is_sfx(self): 

67 return self.trackname.startswith(config["audio"]["sfx_track_prefix"]) 

68 

69 def is_dialogue(self): 

70 sfx_or_music = ( 

71 self.trackname.startswith(config["audio"]["sfx_track_prefix"]) 

72 ) | (self.trackname.startswith(config["audio"]["music_track_prefix"])) 

73 return not sfx_or_music 

74 

75 def to_list(self): 

76 return [getattr(self, key) for key in self.OUTPUT_VALS] 

77 

78 def __str__(self): 

79 as_list = self.to_list() 

80 as_list = [f"{i}" for i in as_list] 

81 return ",".join(as_list) 

82 

83 def __eq__(self, x): 

84 return ( 

85 (self.filename == x.filename) 

86 & (self.sf == x.sf) 

87 & (self.ef == x.ef) 

88 & (self.trackname == x.trackname) 

89 & (self.trackcolor == x.trackcolor) 

90 )