Skip to content

Instantly share code, notes, and snippets.

@dunossauro
Created August 9, 2023 20:20
Show Gist options
  • Save dunossauro/36778ec47640709759d046d9f213dd20 to your computer and use it in GitHub Desktop.
Save dunossauro/36778ec47640709759d046d9f213dd20 to your computer and use it in GitHub Desktop.
<chain id="chain1" out="01:15:33.817">
<property name="length">272030</property>
<property name="eof">pause</property>
<property name="resource">NINJAV_S001_S001_T003.MOV</property>
<property name="mlt_service">avformat-novalidate</property>
<property name="seekable">1</property>
<property name="format">3</property>
<property name="audio_index">0</property>
<property name="video_index">1</property>
<property name="kdenlive:clipname"/>
<property name="kdenlive:clip_type">0</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:id">4</property>
<property name="mute_on_pause">0</property>
<property name="kdenlive:file_size">110681772032</property>
<property name="kdenlive:file_hash">f13bae08b221f86f920e6fcb43a4655f</property>
<property name="kdenlive:audio_max0">172</property>
<property name="meta.media.nb_streams">3</property>
<property name="meta.media.0.stream.type">audio</property>
<property name="meta.media.0.codec.sample_fmt">s32</property>
<property name="meta.media.0.codec.sample_rate">48000</property>
<property name="meta.media.0.codec.channels">2</property>
<property name="meta.media.0.codec.name">pcm_s24le</property>
<property name="meta.media.0.codec.long_name">PCM signed 24-bit little-endian</property>
<property name="meta.media.0.codec.bit_rate">2304000</property>
<property name="meta.attr.0.stream.creation_time.markup">2023-08-03T12:27:20.000000Z</property>
<property name="meta.attr.0.stream.language.markup">eng</property>
<property name="meta.attr.0.stream.vendor_id.markup">[0][0][0][0]</property>
<property name="meta.media.1.stream.type">video</property>
<property name="meta.media.1.stream.frame_rate">60</property>
<property name="meta.media.1.stream.sample_aspect_ratio">1</property>
<property name="meta.media.1.codec.width">1920</property>
<property name="meta.media.1.codec.height">1080</property>
<property name="meta.media.1.codec.rotate">0</property>
<property name="meta.media.1.codec.pix_fmt">yuv422p10le</property>
<property name="meta.media.1.codec.sample_aspect_ratio">0</property>
<property name="meta.media.1.codec.colorspace">709</property>
<property name="meta.media.1.codec.color_trc">1</property>
<property name="meta.media.1.codec.name">prores</property>
<property name="meta.media.1.codec.long_name">Apple ProRes (iCodec Pro)</property>
<property name="meta.media.1.codec.bit_rate">192986501</property>
<property name="meta.attr.1.stream.creation_time.markup">2023-08-03T12:27:20.000000Z</property>
<property name="meta.attr.1.stream.language.markup">eng</property>
<property name="meta.attr.1.stream.vendor_id.markup">appl</property>
<property name="meta.attr.1.stream.encoder.markup">Apple ProRes 422 LT</property>
<property name="meta.attr.major_brand.markup">qt </property>
<property name="meta.attr.minor_version.markup">537199360</property>
<property name="meta.attr.compatible_brands.markup">qt </property>
<property name="meta.attr.creation_time.markup">2023-08-03T12:27:20.000000Z</property>
<property name="meta.attr.make.markup">Atomos</property>
<property name="meta.attr.make-eng.markup">Atomos</property>
<property name="meta.attr.encoder.markup">NinjaV - 10.93.00 </property>
<property name="meta.attr.encoder-eng.markup">NinjaV - 10.93.00 </property>
<property name="meta.attr.com.atomos.hdr.gamut.markup">Rec709</property>
<property name="meta.attr.com.atomos.hdr.gamma.markup">Rec709</property>
<property name="meta.attr.com.atomos.hdr.monitormode.markup">Native</property>
<property name="meta.attr.com.atomos.hdr.range.markup">Legal</property>
<property name="meta.attr.com.apple.proapps.image.{TIFF}.Make.markup">Atomos</property>
<property name="meta.attr.com.apple.proapps.image.{TIFF}.Model.markup">NinjaV</property>
<property name="meta.attr.com.apple.proapps.image.{TIFF}.Software.markup">10.93.00</property>
<property name="meta.attr.timecode.markup">00:00:00:00</property>
<property name="meta.media.sample_aspect_num">1</property>
<property name="meta.media.sample_aspect_den">1</property>
<property name="meta.media.frame_rate_num">60</property>
<property name="meta.media.frame_rate_den">1</property>
<property name="meta.media.colorspace">709</property>
<property name="meta.media.color_trc">1</property>
<property name="meta.media.has_b_frames">0</property>
<property name="meta.media.width">1920</property>
<property name="meta.media.height">1080</property>
<property name="meta.media.color_range">mpeg</property>
<property name="xml">was here</property>
<property name="meta.media.top_field_first">0</property>
<property name="meta.media.progressive">1</property>
<property name="set.test_audio">0</property>
<property name="set.test_image">1</property>
</chain>
<chain id="chain2" out="01:15:33.817">
<property name="length">272030</property>
<property name="eof">pause</property>
<property name="resource">NINJAV_S001_S001_T003.MOV</property>
<property name="mlt_service">avformat-novalidate</property>
<property name="seekable">1</property>
<property name="format">3</property>
<property name="audio_index">0</property>
<property name="video_index">1</property>
<property name="kdenlive:clipname"/>
<property name="kdenlive:clip_type">0</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:id">4</property>
<property name="mute_on_pause">0</property>
<property name="kdenlive:file_size">110681772032</property>
<property name="kdenlive:file_hash">f13bae08b221f86f920e6fcb43a4655f</property>
<property name="kdenlive:audio_max0">172</property>
<property name="meta.media.nb_streams">3</property>
<property name="meta.media.0.stream.type">audio</property>
<property name="meta.media.0.codec.sample_fmt">s32</property>
<property name="meta.media.0.codec.sample_rate">48000</property>
<property name="meta.media.0.codec.channels">2</property>
<property name="meta.media.0.codec.name">pcm_s24le</property>
<property name="meta.media.0.codec.long_name">PCM signed 24-bit little-endian</property>
<property name="meta.media.0.codec.bit_rate">2304000</property>
<property name="meta.attr.0.stream.creation_time.markup">2023-08-03T12:27:20.000000Z</property>
<property name="meta.attr.0.stream.language.markup">eng</property>
<property name="meta.attr.0.stream.vendor_id.markup">[0][0][0][0]</property>
<property name="meta.media.1.stream.type">video</property>
<property name="meta.media.1.stream.frame_rate">60</property>
<property name="meta.media.1.stream.sample_aspect_ratio">1</property>
<property name="meta.media.1.codec.width">1920</property>
<property name="meta.media.1.codec.height">1080</property>
<property name="meta.media.1.codec.rotate">0</property>
<property name="meta.media.1.codec.pix_fmt">yuv422p10le</property>
<property name="meta.media.1.codec.sample_aspect_ratio">0</property>
<property name="meta.media.1.codec.colorspace">709</property>
<property name="meta.media.1.codec.color_trc">1</property>
<property name="meta.media.1.codec.name">prores</property>
<property name="meta.media.1.codec.long_name">Apple ProRes (iCodec Pro)</property>
<property name="meta.media.1.codec.bit_rate">192986501</property>
<property name="meta.attr.1.stream.creation_time.markup">2023-08-03T12:27:20.000000Z</property>
<property name="meta.attr.1.stream.language.markup">eng</property>
<property name="meta.attr.1.stream.vendor_id.markup">appl</property>
<property name="meta.attr.1.stream.encoder.markup">Apple ProRes 422 LT</property>
<property name="meta.attr.major_brand.markup">qt </property>
<property name="meta.attr.minor_version.markup">537199360</property>
<property name="meta.attr.compatible_brands.markup">qt </property>
<property name="meta.attr.creation_time.markup">2023-08-03T12:27:20.000000Z</property>
<property name="meta.attr.make.markup">Atomos</property>
<property name="meta.attr.make-eng.markup">Atomos</property>
<property name="meta.attr.encoder.markup">NinjaV - 10.93.00 </property>
<property name="meta.attr.encoder-eng.markup">NinjaV - 10.93.00 </property>
<property name="meta.attr.com.atomos.hdr.gamut.markup">Rec709</property>
<property name="meta.attr.com.atomos.hdr.gamma.markup">Rec709</property>
<property name="meta.attr.com.atomos.hdr.monitormode.markup">Native</property>
<property name="meta.attr.com.atomos.hdr.range.markup">Legal</property>
<property name="meta.attr.com.apple.proapps.image.{TIFF}.Make.markup">Atomos</property>
<property name="meta.attr.com.apple.proapps.image.{TIFF}.Model.markup">NinjaV</property>
<property name="meta.attr.com.apple.proapps.image.{TIFF}.Software.markup">10.93.00</property>
<property name="meta.attr.timecode.markup">00:00:00:00</property>
<property name="meta.media.sample_aspect_num">1</property>
<property name="meta.media.sample_aspect_den">1</property>
<property name="meta.media.frame_rate_num">60</property>
<property name="meta.media.frame_rate_den">1</property>
<property name="meta.media.colorspace">709</property>
<property name="meta.media.color_trc">1</property>
<property name="meta.media.has_b_frames">0</property>
<property name="meta.media.width">1920</property>
<property name="meta.media.height">1080</property>
<property name="meta.media.color_range">mpeg</property>
<property name="xml">was here</property>
<property name="meta.media.top_field_first">0</property>
<property name="meta.media.progressive">1</property>
<property name="set.test_audio">1</property>
<property name="set.test_image">0</property>
</chain>
@rennerocha
Copy link

from parsel import Selector

xml = """<chain id="chain1" out="01:15:33.817">
  <property name="resource">NINJAV_S001_S001_T003.MOV</property>
  <property name="set.test_audio">1</property>
 </chain>

<chain id="chain2" out="01:15:33.817">
  <property name="resource">NINJAV_S001_S001_T003.MOV</property>
  <property name="set.test_audio">0</property>
 </chain>

 <chain id="chain3" out="01:15:33.817">
  <property name="resource">NINJAV_S002_S002_T002.MOV</property>
  <property name="set.test_audio">1</property>
 </chain>

<chain id="chain4" out="01:15:33.817">
  <property name="resource">NINJAV_S002_S002_T002.MOV</property>
  <property name="set.test_audio">0</property>
 </chain>
"""
sel = Selector(text=xml)

resource = "NINJAV_S001_S001_T003.MOV"
test_audio = "1"

sel.xpath(f"""
    //chain[(
        (./property[(@name='resource' and ./text()='{resource}')])
        and
        (./property[(@name='set.test_audio' and ./text()='{test_audio}')])
    )]/@id
""").getall()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment