PageSourceSearch

https://www.getmusic.shop/assets/FlacParser-BplRBezq.js

js getmusic.shop collected 2026-10-08 23:02:08 UTC 6,940 bytes, 1 lines download raw bytes

1import{i as E}from"./socket-vendor-BZTe4cjS.js";import{A as R,U as o,S as k,b as U,r as m,t as v,m as A,h as g,g as p,j as N,c as I,a as w,F as M}from"./core-BQLAx32k.js";import{A as x}from"./AbstractID3Parser-oO90U5OZ.js";class h{static fromBase64(t){return h.fromBuffer(Uint8Array.from(atob(t),e=>e.charCodeAt(0)))}static fromBuffer(t){return new h(t.length).get(t,0)}constructor(t){this.len=t}get(t,e){const r=R[o.get(t,e)];e+=4;const s=o.get(t,e);e+=4;const i=new k(s,"utf-8").get(t,e);e+=s;const n=o.get(t,e);e+=4;const T=new k(n,"utf-8").get(t,e);e+=n;const P=o.get(t,e);e+=4;const C=o.get(t,e);e+=4;const b=o.get(t,e);e+=4;const L=o.get(t,e);e+=4;const z=o.get(t,e);e+=4;const O=t.slice(e,e+z);return{type:r,format:i,description:T,width:P,height:C,colour_depth:b,indexed_color:L,data:O}}}const d={len:7,get:(a,t)=>({packetType:U.get(a,t),vorbis:new k(6,"ascii").get(a,t+1)})},_={len:23,get:(a,t)=>({version:m.get(a,t+0),channelMode:U.get(a,t+4),sampleRate:m.get(a,t+5),bitrateMax:m.get(a,t+9),bitrateNominal:m.get(a,t+13),bitrateMin:m.get(a,t+17)})};class B{constructor(t,e){this.data=t,this.offset=e}readInt32(){const t=m.get(this.data,this.offset);return this.offset+=4,t}readStringUtf8(){const t=this.readInt32(),e=v(this.data.subarray(this.offset,this.offset+t),"utf-8");return this.offset+=t,e}parseUserComment(){const t=this.offset,e=this.readStringUtf8(),r=e.indexOf("=");return{key:e.substring(0,r).toUpperCase(),value:e.substring(r+1),len:this.offset-t}}}const l=E("music-metadata:parser:ogg:vorbis1");class y extends A("Vorbis"){}class u{constructor(t,e){this.pageSegments=[],this.durationOnLastPage=!0,this.metadata=t,this.options=e}async parsePage(t,e){if(this.lastPageHeader=t,t.headerType.firstPage)this.parseFirstPage(t,e);else{if(t.headerType.continued){if(this.pageSegments.length===0)throw new y("Cannot continue on previous page");this.pageSegments.push(e)}if(t.headerType.lastPage||!t.headerType.continued){if(this.pageSegments.length>0){const r=u.mergeUint8Arrays(this.pageSegments);await this.parseFullPage(r)}this.pageSegments=t.headerType.lastPage?[]:[e]}}}static mergeUint8Arrays(t){const e=t.reduce((s,i)=>s+i.length,0),r=new Uint8Array(e);return t.forEach((s,i,n)=>{const T=n.slice(0,i).reduce((P,C)=>P+C.length,0);r.set(s,T)}),r}async flush(){await this.parseFullPage(u.mergeUint8Arrays(this.pageSegments))}async parseUserComment(t,e){const s=new B(t,e).parseUserComment();return await this.addTag(s.key,s.value),s.len}async addTag(t,e){if(t==="METADATA_BLOCK_PICTURE"&&typeof e=="string"){if(this.options.skipCovers){l("Ignore picture");return}e=h.fromBase64(e),l(`Push picture: id=${t}, format=${e.format}`)}else l(`Push tag: id=${t}, value=${e}`);await this.metadata.addTag("vorbis",t,e)}calculateDuration(t){this.lastPageHeader&&(t||this.lastPageHeader.headerType.lastPage)&&this.metadata.format.sampleRate&&this.lastPageHeader.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",this.lastPageHeader.absoluteGranulePosition),this.metadata.setFormat("duration",this.lastPageHeader.absoluteGranulePosition/this.metadata.format.sampleRate))}parseFirstPage(t,e){this.metadata.setFormat("codec","Vorbis I"),this.metadata.setFormat("hasAudio",!0),l("Parse first page");const r=d.get(e,0);if(r.vorbis!=="vorbis")throw new y("Metadata does not look like Vorbis");if(r.packetType===1){const s=_.get(e,d.len);this.metadata.setFormat("sampleRate",s.sampleRate),this.metadata.setFormat("bitrate",s.bitrateNominal),this.metadata.setFormat("numberOfChannels",s.channelMode),l("sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s",s.sampleRate,s.bitrateNominal,s.channelMode)}else throw new y("First Ogg page should be type 1: the identification header")}async parseFullPage(t){const e=d.get(t,0);switch(l("Parse full page: type=%s, byteLength=%s",e.packetType,t.byteLength),e.packetType){case 3:return this.parseUserCommentList(t,d.len)}}async parseUserCommentList(t,e){const r=m.get(t,e);e+=4,e+=r;let s=m.get(t,e);for(e+=4;s-- >0;)e+=await this.parseUserComment(t,e)}}const c={STREAMINFO:0,PADDING:1,APPLICATION:2,SEEKTABLE:3,VORBIS_COMMENT:4,CUESHEET:5,PICTURE:6},D={len:4,get:(a,t)=>({lastBlock:N(a,t,7),type:p(a,t,1,7),length:g.get(a,t+1)})},F={len:34,get:(a,t)=>({minimumBlockSize:w.get(a,t),maximumBlockSize:w.get(a,t+2)/1e3,minimumFrameSize:g.get(a,t+4),maximumFrameSize:g.get(a,t+7),sampleRate:g.get(a,t+10)>>4,channels:p(a,t+12,4,3)+1,bitsPerSample:p(a,t+12,7,5)+1,totalSamples:p(a,t+13,4,36),fileMD5:new I(16).get(a,t+18)})},H=E("music-metadata:parser:FLAC");class S extends A("FLAC"){}class $ extends x{constructor(){super(...arguments),this.vorbisParser=new u(this.metadata,this.options)}
1async postId3v2Parse(){if((await this.tokenizer.readToken(M)).toString()!=="fLaC")throw new S("Invalid FLAC preamble");let e;do e=await this.tokenizer.readToken(D),await this.parseDataBlock(e);while(!e.lastBlock);if(this.tokenizer.fileInfo.size&&this.metadata.format.duration){const r=this.tokenizer.fileInfo.size-this.tokenizer.position;this.metadata.setFormat("bitrate",8*r/this.metadata.format.duration)}}async parseDataBlock(t){switch(H(`blockHeader type=${t.type}, length=${t.length}`),t.type){case c.STREAMINFO:return this.readBlockStreamInfo(t.length);case c.PADDING:break;case c.APPLICATION:break;case c.SEEKTABLE:break;case c.VORBIS_COMMENT:return this.readComment(t.length);case c.CUESHEET:break;case c.PICTURE:await this.parsePicture(t.length);return;default:this.metadata.addWarning(`Unknown block type: ${t.type}`)}return this.tokenizer.ignore(t.length).then()}async readBlockStreamInfo(t){if(t!==F.len)throw new S("Unexpected block-stream-info length");const e=await this.tokenizer.readToken(F);this.metadata.setFormat("container","FLAC"),this.processsStreamInfo(e)}processsStreamInfo(t){this.metadata.setFormat("codec","FLAC"),this.metadata.setFormat("hasAudio",!0),this.metadata.setFormat("lossless",!0),this.metadata.setFormat("numberOfChannels",t.channels),this.metadata.setFormat("bitsPerSample",t.bitsPerSample),this.metadata.setFormat("sampleRate",t.sampleRate),t.totalSamples>0&&this.metadata.setFormat("duration",t.totalSamples/t.sampleRate)}async readComment(t){const e=await this.tokenizer.readToken(new I(t));return this.parseComment(e)}async parseComment(t){const e=new B(t,0),r=e.readStringUtf8();r.length>0&&this.metadata.setFormat("tool",r);const s=e.readInt32(),i=new Array(s);for(let n=0;n<s;n++)i[n]=e.parseUserComment();await Promise.all(i.map(n=>(n.key==="ENCODER"&&this.metadata.setFormat("tool",n.value),this.addTag(n.key,n.value))))}async parsePicture(t){return this.options.skipCovers?this.tokenizer.ignore(t):this.addPictureTag(await this.tokenizer.readToken(new h(t)))}addPictureTag(t){return this.addTag("METADATA_BLOCK_PICTURE",t)}addTag(t,e){return this.vorbisParser.addTag(t,e)}}const j=Object.freeze(Object.defineProperty({__proto__:null,FlacParser:$},Symbol.toStringTag,{value:"Module"}));export{D as B,$ as F,u as V,c as a,h as b,F as c,j as d};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.