A decentralized music tracking and discovery platform built on AT Protocol 🎵

[webscrobbler] make duration optional

+83 -1
+83 -1
crates/webscrobbler/src/types.rs
··· 64 64 pub album_artist: Option<String>, 65 65 pub artist: String, 66 66 pub current_time: Option<u32>, 67 - pub duration: u32, 67 + pub duration: Option<u32>, 68 68 pub is_playing: bool, 69 69 pub is_podcast: bool, 70 70 pub origin_url: Option<String>, ··· 708 708 query, 709 709 r#"track:"Let It Talk To Me" artist:"Sean Paul" artist:"INNA""# 710 710 ); 711 + } 712 + 713 + #[test] 714 + fn test_kexp_scrobble_request() { 715 + let json = r#" 716 + { 717 + "eventName": "nowplaying", 718 + "time": 1749848844651, 719 + "data": { 720 + "song": { 721 + "parsed": { 722 + "track": "ENERGY", 723 + "artist": "Disclosure", 724 + "albumArtist": null, 725 + "album": "ENERGY", 726 + "duration": null, 727 + "uniqueID": null, 728 + "currentTime": null, 729 + "isPlaying": true, 730 + "trackArt": "https://ia803209.us.archive.org/7/items/mbid-6f1db1e3-71b3-4524-b0fe-c1e29f361dfe/mbid-6f1db1e3-71b3-4524-b0fe-c1e29f361dfe-26365923265_thumb250.jpg", 731 + "isPodcast": false, 732 + "originUrl": "https://www.kexp.org/", 733 + "scrobblingDisallowedReason": null 734 + }, 735 + "processed": { 736 + "track": "ENERGY", 737 + "artist": "Disclosure", 738 + "albumArtist": null, 739 + "album": "ENERGY", 740 + "duration": null 741 + }, 742 + "noRegex": { 743 + "track": "ENERGY", 744 + "artist": "Disclosure", 745 + "albumArtist": null, 746 + "album": "ENERGY", 747 + "duration": null 748 + }, 749 + "flags": { 750 + "isScrobbled": false, 751 + "isCorrectedByUser": false, 752 + "isRegexEditedByUser": { 753 + "track": false, 754 + "artist": false, 755 + "album": false, 756 + "albumArtist": false 757 + }, 758 + "isAlbumFetched": false, 759 + "isValid": true, 760 + "isMarkedAsPlaying": true, 761 + "isSkipped": false, 762 + "isReplaying": true, 763 + "hasBlockedTag": false, 764 + "isLovedInService": null, 765 + "finishedProcessing": true 766 + }, 767 + "metadata": { 768 + "userloved": false, 769 + "startTimestamp": 1749848842, 770 + "label": "KEXP", 771 + "trackArtUrl": "https://lastfm.freetls.fastly.net/i/u/300x300/a18f5dadcc38ad3d264e74ce51d9cf08.png", 772 + "artistUrl": "https://www.last.fm/music/Disclosure", 773 + "trackUrl": "https://www.last.fm/music/Disclosure/_/ENERGY", 774 + "albumUrl": "https://www.last.fm/music/Various+Artists/Festival+Dance", 775 + "userPlayCount": 0 776 + }, 777 + "connector": { 778 + "label": "KEXP", 779 + "matches": [ 780 + "*://*.kexp.org/*" 781 + ], 782 + "js": "kexp.js", 783 + "id": "kexp" 784 + }, 785 + "controllerTabId": 943739308 786 + } 787 + } 788 + } 789 + "#; 790 + 791 + let result = serde_json::from_str::<ScrobbleRequest>(json); 792 + assert!(result.is_ok(), "Failed to parse JSON: {:?}", result.err()); 711 793 } 712 794 }