Created
March 18, 2024 05:50
-
-
Save RoyalIcing/360382b61d5de4a7b32fc39765eebcab to your computer and use it in GitHub Desktop.
YouTube Parser with Orb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module $YouTubeURLParser | |
(memory (export "memory") 1) | |
(global $YouTubeURLParser.Input.bump_offset (mut i32) (i32.const 0)) | |
(func $YouTubeURLParser.Input.alloc! (param $byte_count i32) (result i32) | |
(local $new_ptr i32) | |
(global.get $YouTubeURLParser.Input.bump_offset) | |
(local.set $new_ptr) | |
(i32.gt_u (i32.add (local.get $new_ptr) (local.get $byte_count)) (i32.const 65536)) | |
(if | |
(then | |
unreachable | |
) | |
) | |
(i32.gt_u (i32.add (local.get $new_ptr) (local.get $byte_count)) (i32.mul (memory.size) (i32.const 65536))) | |
(if | |
(then | |
(memory.grow (i32.const 1)) | |
drop | |
) | |
) | |
(i32.add (local.get $new_ptr) (local.get $byte_count)) | |
(global.set $YouTubeURLParser.Input.bump_offset) | |
(local.get $new_ptr) | |
) | |
(func $YouTubeURLParser.Input.rewind | |
(i32.const 0) | |
(global.set $YouTubeURLParser.Input.bump_offset) | |
) | |
(func $input_offset (export "input_offset") (result i32) | |
(i32.const 0) | |
) | |
(func $parse (export "parse") (result i32) | |
(local $input_offset i32) | |
(i32.const 0) | |
(local.set $input_offset) | |
(block $OptionalScheme | |
(i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 3))) (i32.const 112)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 2))) (i32.const 116)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 1))) (i32.const 116)) (i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 104))))) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 4)) | |
(local.set $input_offset) | |
) | |
(else | |
(br $OptionalScheme) | |
) | |
) | |
(i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 115)) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 1)) | |
(local.set $input_offset) | |
) | |
) | |
(i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 58)) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 1)) | |
(local.set $input_offset) | |
) | |
(else | |
(br $OptionalScheme) | |
) | |
) | |
) | |
(i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 1))) (i32.const 47)) (i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 47))) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 2)) | |
(local.set $input_offset) | |
) | |
) | |
(block $ShortDomain | |
(local.get $input_offset) | |
(block $FullDomain | |
(i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 3))) (i32.const 46)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 2))) (i32.const 119)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 1))) (i32.const 119)) (i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 119))))) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 4)) | |
(local.set $input_offset) | |
) | |
) | |
(i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 10))) (i32.const 109)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 9))) (i32.const 111)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 8))) (i32.const 99)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 7))) (i32.const 46)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 6))) (i32.const 101)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 5))) (i32.const 98)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 4))) (i32.const 117)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 3))) (i32.const 116)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 2))) (i32.const 117)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 1))) (i32.const 111)) (i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 121)))))))))))) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 11)) | |
(local.set $input_offset) | |
) | |
(else | |
(br $FullDomain) | |
) | |
) | |
(i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 8))) (i32.const 61)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 7))) (i32.const 118)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 6))) (i32.const 63)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 5))) (i32.const 104)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 4))) (i32.const 99)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 3))) (i32.const 116)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 2))) (i32.const 97)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 1))) (i32.const 119)) (i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 47)))))))))) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 9)) | |
(local.set $input_offset) | |
) | |
(else | |
(br $FullDomain) | |
) | |
) | |
(br $ShortDomain) | |
) | |
(local.set $input_offset) | |
(i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 8))) (i32.const 47)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 7))) (i32.const 101)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 6))) (i32.const 98)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 5))) (i32.const 46)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 4))) (i32.const 117)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 3))) (i32.const 116)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 2))) (i32.const 117)) (i32.and (i32.eq (i32.load8_u (i32.add (local.get $input_offset) (i32.const 1))) (i32.const 111)) (i32.eq (i32.load8_u (local.get $input_offset)) (i32.const 121)))))))))) | |
(if | |
(then | |
(i32.add (local.get $input_offset) (i32.const 9)) | |
(local.set $input_offset) | |
) | |
(else | |
(return (i32.const 0)) | |
) | |
) | |
) | |
(local.get $input_offset) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment