-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You could now check what anime is coming or should come today. You could go to myanimelist website to check out more Former-commit-id: 27774c4
- Loading branch information
Showing
8 changed files
with
150 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { MajorLink } from '../../value'; | ||
import { Alert } from 'react-native'; | ||
|
||
export default class AnimeSchedule { | ||
getScheduleForToday() { | ||
return new Promise((success, failure) => { | ||
// Loading data here | ||
let weekdays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; | ||
fetch(MajorLink.Schedule).then((html) => html.text()).then((htmlText) => { | ||
var HTMLParser = require('fast-html-parser'); | ||
let weekdayClass = '.js-seasonal-anime-list-key-' + weekdays[new Date().getDay() - 1]; | ||
var root = HTMLParser.parse(htmlText).querySelector(weekdayClass); | ||
// Somehow, nothing is found | ||
if (root == null) success([]); | ||
|
||
var animeSchedule = []; | ||
for (var i = 0; i < root.childNodes.length; i++) { | ||
var curr = root.childNodes[i]; | ||
// Ignore whitespaces and header | ||
if (curr.isWhitespace || curr.classNames[0] == 'anime-header') continue; | ||
curr = curr.childNodes; | ||
console.log(curr); | ||
let name = this.cleanText(curr[2].text); | ||
var link = ''; let linkPath = curr[0].childNodes[1].childNodes; | ||
if (linkPath[1].isWhitespace) link = linkPath[0].childNodes[1].attributes.href; | ||
else link = linkPath[1].childNodes[1].attributes.href; | ||
let time = this.cleanText(curr[6].childNodes[1].text).split(' -')[1]; | ||
let rating = '⭐️ ' + this.cleanText(curr[6].childNodes[3].childNodes[3].text); | ||
animeSchedule.push({name: name, link: link, time: time, rating: rating}); | ||
} | ||
console.log(animeSchedule); | ||
success(animeSchedule); | ||
}).catch((error) => { | ||
// console.error(error); | ||
Alert.alert('Error', 'Schedule not found'); | ||
failure(error); | ||
}); | ||
}) | ||
} | ||
|
||
cleanText(input) { | ||
var noNextLine = input.split('\n').join(' '); | ||
return noNextLine.split(' ').join(''); | ||
} | ||
} |
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,57 @@ | ||
import React, { Component } from 'react'; | ||
import { View, FlatList, Text, Linking } from 'react-native'; | ||
import { styles } from './ScheduleStyles'; | ||
import AnimeSchedule from '../helper/core/AnimeSchedule'; | ||
import { LoadingIndicator, SmartTouchable } from '../component'; | ||
|
||
class Schedule extends Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
data: [], isReady: false, noAnime: false | ||
} | ||
} | ||
|
||
componentWillMount() { | ||
let schedule = new AnimeSchedule(); | ||
schedule.getScheduleForToday().then((scheduleList) => { | ||
if (scheduleList == []) { | ||
this.setState({noAnime: true, isReady: true}) | ||
} else { | ||
this.setState({data: scheduleList, isReady: true}) | ||
} | ||
}) | ||
} | ||
|
||
scheduleKey = (data) => data.name; | ||
render() { | ||
const { data, isReady, noAnime } = this.state; | ||
const { mainViewStyle, noAnimeStyle, textStyle, cellViewStyle, titleStyle, infoStyle, timeStyle } = styles; | ||
if (isReady == false) return <LoadingIndicator /> | ||
else if (noAnime) { | ||
return ( | ||
<View style={noAnimeStyle}> | ||
<Text style={textStyle}>No Anime today 0_0</Text> | ||
</View> | ||
) | ||
} else return ( | ||
<View style={mainViewStyle}> | ||
<FlatList data={data} keyExtractor={this.scheduleKey} renderItem={({item}) => { | ||
return ( | ||
<View style={cellViewStyle}> | ||
<SmartTouchable onPress={() => Linking.openURL(item.link)}> | ||
<View> | ||
<Text style={titleStyle}>{item.name}</Text> | ||
<Text style={timeStyle}>{item.time + ' ' + item.rating }</Text> | ||
</View> | ||
</SmartTouchable> | ||
</View> | ||
) | ||
}} automaticallyAdjustContentInsets={false} showsVerticalScrollIndicator={false} | ||
ListHeaderComponent={<Text style={textStyle}>Data are from MyAnimeList</Text>} /> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
export {Schedule}; |
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,32 @@ | ||
import { StyleSheet } from 'react-native'; | ||
import { BlueColour } from '../value'; | ||
|
||
export const styles = StyleSheet.create({ | ||
noAnimeStyle: { | ||
flex: 1, | ||
justifyContent: 'center' | ||
}, | ||
mainViewStyle: { | ||
flex: 1 | ||
}, | ||
textStyle: { | ||
textAlign: 'center', | ||
color: BlueColour, | ||
fontSize: 16 | ||
}, | ||
cellViewStyle: { | ||
flex: 1, | ||
padding: 8 | ||
}, | ||
titleStyle: { | ||
textAlign: 'center', | ||
color: 'black', | ||
fontSize: 20 | ||
}, | ||
infoStyle: { | ||
textAlign: 'center' | ||
}, | ||
timeStyle: { | ||
textAlign: 'center' | ||
} | ||
}) |
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 |
---|---|---|
|
@@ -21,7 +21,7 @@ export const MicrosoftStore = 'https://www.microsoft.com/store/p/anime-go/9mx3qr | |
export const Email = 'mailto:[email protected]'; | ||
|
||
export const AD_IS_OPTIONAL = 'This is completely optional.' | ||
export const VERSION = '1.0.747'; | ||
export const VERSION = '1.0.77777'; | ||
|
||
export const ScreenIndex = { | ||
NewRelease: 0, | ||
|
@@ -30,7 +30,8 @@ export const ScreenIndex = { | |
Popular: 3, | ||
Genre: 4, | ||
Setting: 5, | ||
ToWatch: 6 | ||
ToWatch: 6, | ||
Schedule: 7 | ||
} | ||
|
||
export const MajorLink = { | ||
|
@@ -42,4 +43,5 @@ export const MajorLink = { | |
Search: 'https://gogoanime.se/search.html?keyword=', | ||
Episode: 'https://gogoanime.se/load-list-episode?ep_start=', | ||
Popular: 'https://gogoanime.se/popular.html?page=', | ||
Schedule: 'https://myanimelist.net/anime/season/schedule' | ||
} |