MCPcopy Create free account
hub / github.com/cfinke/Channel-Two / getDuration

Function getDuration

channel-two.js:940–976  ·  view source on GitHub ↗

* Find the duration, in seconds, of a given file. * * @return int|bool The duration, or false if not available.

( filePath )

Source from the content-addressed store, hash-verified

938 * @return int|bool The duration, or false if not available.
939 */
940 function getDuration( filePath ) {
941 if ( logLevel >= 2 ) console.log( "getDuration(" + filePath + ")" );
942
943 if ( filePath in programming.content_index ) {
944 if ( logLevel >= 2 ) console.log( "Found " + filePath + " in content_index" );
945
946 if ( 'duration' in programming.content_index[ filePath ] ) {
947 return programming.content_index[ filePath ].duration;
948 } else {
949 if ( logLevel >= 2 ) console.log( "But didn't find duration in programming.content_index[ filePath ]" );
950 }
951 }
952
953 if ( filePath in programming.ad_index ) {
954 if ( logLevel >= 2 ) console.log( "Found " + filePath + " in ad_index" );
955
956 if ( 'duration' in programming.ad_index[ filePath ] ) {
957 return programming.ad_index[ filePath ].duration;
958 } else {
959 if ( logLevel >= 2 ) console.log( "But didn't find duration in programming.ad_index[ filePath ]" );
960 }
961 }
962
963 if ( logLevel >= 2 ) console.log( "Could not find " + filePath + " with duration in content_index or ad_index" );
964
965 if ( 'durations' in localStorage ) {
966 let durations = JSON.parse( localStorage.durations );
967
968 if ( filePath in durations ) {
969 if ( logLevel >= 2 ) console.log( "Found duration in localStorage: " + durations[ filePath ] );
970
971 return durations[ filePath ];
972 }
973 }
974
975 return false;
976 }
977
978 /**
979 * If a caption file is available for a file, return its path.

Callers 1

adBreakFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected