File tree Expand file tree Collapse file tree 4 files changed +69
-1
lines changed Expand file tree Collapse file tree 4 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,15 @@ export class PayloadService extends ApiService {
114
114
list_count : albumDetails . list_count ,
115
115
list_type : albumDetails . list_type ,
116
116
songs : albumDetails . list . map ( ( current ) => {
117
+
118
+ /**
119
+ *
120
+ * id: string
121
+ title: string
122
+ artist: string
123
+ artwork: string
124
+ url: string
125
+ */
117
126
return {
118
127
id : current . id ,
119
128
title : current . title . replaceAll ( """ , '"' ) ,
Original file line number Diff line number Diff line change 1
- import React , { memo } from "react"
1
+ import React , { memo , useEffect } from "react"
2
2
import { View } from "react-native"
3
3
import { audioBookImageBaseUrl } from "../../api/base/constrants"
4
+ import { useAppDispatch } from "../../hooks/store.hook"
4
5
import { Docs } from "../../screens/Home/Albums"
6
+ import { audioBookDetails } from "../../store/actions/audioBookDetails.action"
5
7
import Header from "../DetailsScreen/Header"
6
8
interface AudioBookData {
7
9
key : string
@@ -15,6 +17,21 @@ export interface AudioBookDetailsProps {
15
17
}
16
18
const AudioBookDetails : React . FC < AudioBookDetailsProps > = ( { route } ) => {
17
19
const { audios } = route . params
20
+ const dispatch = useAppDispatch ( )
21
+
22
+ const get = async ( ) => {
23
+ try {
24
+ dispatch (
25
+ audioBookDetails . getAudioBookDetails ( { identifier : audios . identifier } )
26
+ )
27
+ } catch ( error ) {
28
+ console . log ( error )
29
+ }
30
+ }
31
+
32
+ useEffect ( ( ) => {
33
+ get ( )
34
+ } , [ ] )
18
35
return (
19
36
< View >
20
37
< Header
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ export interface AudioBookScreenInterface {
27
27
28
28
const Albums = ( ) => {
29
29
const audioData = TypedSelectorHook ( audioBooks )
30
+ console . log ( audioData . data [ 0 ] . audios [ 0 ] )
30
31
const dispatch = useAppDispatch ( )
31
32
useEffect ( ( ) => {
32
33
dispatch ( getAudioBooks ( ) )
Original file line number Diff line number Diff line change
1
+ import { createAsyncThunk } from "@reduxjs/toolkit" ;
2
+ import axios from "axios" ;
3
+ import { PayloadService } from "../../api/service/Payload.service" ;
4
+ type Prop = {
5
+ identifier : string
6
+ }
7
+ interface AudioDetails {
8
+ name : string ;
9
+ source : string ;
10
+ creator : string ;
11
+ title : string ;
12
+ track : string ;
13
+ album : string ;
14
+ genre : string ;
15
+ bitrate : string ;
16
+ length : string ;
17
+ format : string ;
18
+ original : string ;
19
+ mtime : string ;
20
+ size : string ;
21
+ md5 : string ;
22
+ crc32 : string ;
23
+ sha1 : string ;
24
+ }
25
+ type AudioDetailsResponse = {
26
+ result : Array < AudioDetails >
27
+ }
28
+ class AudioBookeDetails extends PayloadService {
29
+ public getAudioBookDetails = createAsyncThunk ( "/audioBookeDetails" , async ( prop : Prop , ASYNC ) => {
30
+ try {
31
+ const response = await axios . get < AudioDetailsResponse > ( `https://archive.org/metadata/${ prop . identifier } /files?output=json` )
32
+ const responseData = response . data . result . filter ( ( current ) => current . source == "original" && current . track != null )
33
+ console . log ( prop . identifier )
34
+ console . log ( responseData [ 0 ] . name )
35
+ } catch ( error : any ) {
36
+ return ASYNC . rejectWithValue ( error ?. message )
37
+ }
38
+ } )
39
+ }
40
+
41
+ export const audioBookDetails = new AudioBookeDetails ( )
You can’t perform that action at this time.
0 commit comments