mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
2.2 KiB
JavaScript
1 line
2.2 KiB
JavaScript
(()=>(t,n)=>{function e(t,n,e){if(n in t){Object.defineProperty(t,n,{value:e,enumerable:true,configurable:true,writable:true})}else{t[n]=e}return t}const i={TopLeft:7,TopCenter:8,TopRight:9,BottomLeft:1,BottomCenter:2,BottomRight:3};const o=t=>Object.entries(i).filter((([,n])=>n===t)).map((([t])=>t)).shift();let r;(function(t){t[t["VerySmall"]=1]="VerySmall";t[t["Small"]=2]="Small";t[t["Medium"]=3]="Medium";t[t["Large"]=4]="Large";t[t["VeryLarge"]=5]="VeryLarge"})(r||(r={}));class a{constructor(t){e(this,"config",void 0);this.config=Object.assign(a.defaultConfig,t)}async getAssMeta(){const{convertHexColorForStyle:t}=await n.importAsync("ass-utils");const e=t(this.config.color);const o=t("#000000",this.config.opacity);const r=[];const a=(10*(this.config.size-3)+48)*this.config.height/720;console.log(a);for(const[t,n]of Object.entries(i)){r.push(`Style: ${t},微软雅黑,${a},${e},${e},${o},${o},0,0,0,0,100,100,0,0,3,${this.config.boxPadding},0,${n},${this.config.boxMargin},${this.config.boxMargin},${this.config.boxMargin},0`)}return`\n[Script Info]\n; Script generated by Bilibili Evolved Danmaku Converter\n; https://github.com/the1812/Bilibili-Evolved/\nTitle: ${this.config.title}\nScriptType: v4.00+\nPlayResX: ${this.config.width}\nPlayResY: ${this.config.height}\nTimer: 10.0000\nWrapStyle: 0\nScaledBorderAndShadow: no\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n${r.join("\n")}\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text`.trim()}async convertToAss(t){const{convertTimeByEndTime:e,normalizeContent:i}=await n.importAsync("ass-utils");const r=await this.getAssMeta();return r+"\n"+t.map((t=>{const[n,r]=e(t.from,t.to);const a=`Dialogue: 0,${n},${r},${o(this.config.location)},,0,0,0,,${i(t.content)}`;return a})).join("\n")}}e(a,"defaultConfig",void 0);a.defaultConfig={title:"",color:"#ffffff",width:1920,height:1080,size:r.Medium,opacity:.5,location:i.BottomCenter,boxPadding:1,boxMargin:32};return{export:{SubtitleConverter:a,SubtitleLocation:i,SubtitleSize:r}}})(); |