This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1c1459
commit 925d656
Showing
10 changed files
with
261 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { View, StyleSheet, ScrollView, Image, Pressable } from "react-native"; | ||
import { Text, TextInput, useTheme } from "react-native-paper"; | ||
import ReactNativeBlobUtil from "react-native-blob-util"; | ||
import ContentCard from "../components/ContentCard"; | ||
import CentredActivityIndicator from "../components/CentredActivityIndicator"; | ||
|
||
const EntireSeasonDownloadScreen = ({ navigation }) => { | ||
const theme = useTheme(); | ||
|
||
const [data, setData] = useState(null); | ||
const [featured, setFeatured] = useState(null); | ||
const [searchText, setSearchText] = useState(""); | ||
const [use, setUse] = useState([]); | ||
|
||
useEffect(() => { | ||
ReactNativeBlobUtil.fs | ||
.readFile(ReactNativeBlobUtil.fs.dirs.DocumentDir + "/WeCima.json") | ||
.then(data => { | ||
const parsedData = Object.entries(JSON.parse(data)); | ||
setData(parsedData); | ||
setFeatured( | ||
parsedData.splice(parsedData.length - 11, parsedData.length), | ||
); | ||
setUse(parsedData.splice(parsedData.length - 11, parsedData.length)); | ||
}); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (data && searchText != "") { | ||
var searched = data.filter(item => { | ||
if ( | ||
item[1]["Title"] | ||
.toLowerCase() | ||
.includes(searchText.toLocaleLowerCase()) | ||
) { | ||
return item; | ||
} else { | ||
// pass | ||
} | ||
}); | ||
|
||
if (searched.length > 0) { | ||
setUse(searched); | ||
} else { | ||
setUse(false); | ||
} | ||
} else { | ||
// pass | ||
} | ||
}, [searchText]); | ||
|
||
useEffect(() => { | ||
if (searchText === "") { | ||
setUse(featured); | ||
} else { | ||
// pass | ||
} | ||
}, [searchText]); | ||
|
||
if (data && featured) { | ||
return ( | ||
<ScrollView style={{ flex: 1 }} showsVerticalScrollIndicator={false}> | ||
<View style={styles.searchBarParentStyle}> | ||
<TextInput | ||
placeholder="Search" | ||
mode="flat" | ||
style={styles.searchBarStyle} | ||
left={<TextInput.Icon icon="magnify" color="grey" />} | ||
underlineColor="transparent" | ||
activeUnderlineColor="transparent" | ||
cursorColor="black" | ||
onChangeText={text => setSearchText(text)} | ||
/> | ||
</View> | ||
|
||
{use ? ( | ||
<View | ||
style={{ | ||
flexDirection: "row", | ||
flexWrap: "wrap", | ||
justifyContent: "center", | ||
}}> | ||
{use.map(item => { | ||
return ( | ||
<ContentCard | ||
imageSource={ | ||
item[1]["Image Source"] | ||
? item[1]["Image Source"] | ||
: "https://imgpile.com/images/TPDrVl.jpg" | ||
} | ||
title={ | ||
item[1]["Title"] + " season " + item[1]["Season Number"] | ||
} | ||
id={item[1]["Source"]} | ||
width={180} | ||
height={270} | ||
rating={`S${item[1]["Season Number"]}`} | ||
category={"WeCima"} | ||
navigation={navigation} | ||
key={item[0]} | ||
/> | ||
); | ||
})} | ||
</View> | ||
) : ( | ||
<View style={styles.imageParentStyle}> | ||
<Image | ||
source={require("../assets/NotFound.png")} | ||
style={{ width: 860 * 0.3, height: 571 * 0.3 }} | ||
/> | ||
<Text | ||
style={{ | ||
...styles.notFoundTextStyle, | ||
color: theme.colors.primary, | ||
}}> | ||
Not Found | ||
</Text> | ||
<Text style={styles.descriptionTextStyle}> | ||
Sorry, the keywords you entered could not be found. Try to check | ||
again or search with different keywords. | ||
</Text> | ||
</View> | ||
)} | ||
</ScrollView> | ||
); | ||
} else { | ||
return <CentredActivityIndicator />; | ||
} | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
searchBarStyle: { | ||
margin: 20, | ||
borderRadius: 10, | ||
borderTopRightRadius: 10, | ||
borderTopLeftRadius: 10, | ||
flex: 1, | ||
}, | ||
searchBarParentStyle: { | ||
flexDirection: "row", | ||
justifyContent: "space-around", | ||
alignItems: "center", | ||
}, | ||
iconStyle: { | ||
marginRight: 20, | ||
borderRadius: 15, | ||
padding: 15, | ||
}, | ||
imageParentStyle: { | ||
alignItems: "center", | ||
flex: 1, | ||
justifyContent: "center", | ||
}, | ||
notFoundTextStyle: { | ||
fontWeight: "bold", | ||
fontSize: 26, | ||
margin: 20, | ||
}, | ||
descriptionTextStyle: { | ||
textAlign: "center", | ||
marginHorizontal: 10, | ||
fontSize: 16, | ||
letterSpacing: 0.75, | ||
}, | ||
}); | ||
|
||
export default EntireSeasonDownloadScreen; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useState } from "react"; | ||
import { Linking, View } from "react-native"; | ||
import { ActivityIndicator, Button } from "react-native-paper"; | ||
import WebView from "react-native-webview"; | ||
|
||
const WeCimaExtractionScreen = ({ route }) => { | ||
const { id } = route.params; | ||
const [qualities, setQualities] = useState(null); | ||
|
||
const jsCode = ` | ||
const qualities = {}; | ||
const items = [...document.getElementsByClassName("Season--Download--Wecima--Single")[0].querySelectorAll("a")]; | ||
items.forEach((item) => { | ||
const link = item.getAttribute("href"); | ||
const resolution = item.querySelector("resolution").innerText; | ||
qualities[resolution] = link; | ||
}); | ||
window.ReactNativeWebView.postMessage(JSON.stringify(qualities)); | ||
`; | ||
|
||
if (!qualities) { | ||
return ( | ||
<View style={{ flex: 1, justifyContent: "center" }}> | ||
<ActivityIndicator size={50} /> | ||
<View> | ||
<WebView | ||
source={{ uri: `https://wecima.tube/series/${id}` }} | ||
injectedJavaScript={jsCode} | ||
onMessage={event => | ||
setQualities(JSON.parse(event.nativeEvent.data)) | ||
} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
} else { | ||
return ( | ||
<View style={{ flex: 1, justifyContent: "center" }}> | ||
{Object.entries(qualities).map(quality => { | ||
return ( | ||
<Button | ||
mode="outlined" | ||
style={{ marginTop: 10, borderWidth: 0 }} | ||
labelStyle={{ fontSize: 18, padding: 10 }} | ||
onPress={() => Linking.openURL(quality[1])}> | ||
{quality[0]} | ||
</Button> | ||
); | ||
})} | ||
</View> | ||
); | ||
} | ||
}; | ||
|
||
export default WeCimaExtractionScreen; |