Skip to content

Commit

Permalink
Schedule is done
Browse files Browse the repository at this point in the history
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
HenryQuan committed Mar 21, 2018
1 parent d282182 commit 99d307a
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 9 deletions.
6 changes: 3 additions & 3 deletions AnimeGo/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ android {
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.yihengquan.gogoanime"
applicationId "com.yihengquan.gogoanime.debug"
minSdkVersion 16
targetSdkVersion 25
versionCode 8
versionName "1.0.747"
versionCode 9
versionName "1.0.77777"
ndk {
abiFilters "armeabi-v7a", "x86"
}
Expand Down
8 changes: 6 additions & 2 deletions AnimeGo/src/app/App.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ScrollView, View, Image, Text, StatusBar, DrawerLayoutAndroid, ToastAnd
import { Router, Scene, Actions } from 'react-native-router-flux';
import { DrawerCell, SmartTouchable } from '../component';
import { Divider, Button, Icon } from 'react-native-elements';
import { NewRelease, NewSeason, Movie, Popular, Genre, Setting, GenreInfo, WatchAnime, AnimeDetail, SearchAnime, SubCategory, ToWatch } from '../screen';
import { NewRelease, NewSeason, Movie, Popular, Genre, Setting, GenreInfo, WatchAnime, AnimeDetail, SearchAnime, SubCategory, ToWatch, Schedule } from '../screen';
import { AnimeGoColour, StatusBarColour, ScreenIndex } from '../value';
import { styles } from './AppStyle';
import { DataManager } from '../helper/';
Expand All @@ -33,6 +33,8 @@ export default class App extends Component {
<Scene key='root' titleStyle={naviTitleStyle} headerTintColor='white' navigationBarStyle={naviBarStyle} backTitle='Back' renderLeftButton={this.renderLeftBtn}>
<Scene key='NewRelease' component={NewRelease} title='New Release' initial/>
<Scene key='NewSeason' component={NewSeason} title='New Season'/>
<Scene key='Schedule' component={Schedule} title='Schedule'/>

<Scene key='Movie' component={Movie} title='Movie'/>
<Scene key='Popular' component={Popular} title='Popular'/>

Expand Down Expand Up @@ -62,7 +64,7 @@ export default class App extends Component {
</View>
<DrawerCell text='New Release' onPress={() => this.onChangingScreen(ScreenIndex.NewRelease)}/>
<DrawerCell text='New Season' onPress={() => this.onChangingScreen(ScreenIndex.NewSeason)}/>
<DrawerCell text='Schedule'/>
<DrawerCell text='Schedule' onPress={() => this.onChangingScreen(ScreenIndex.Schedule)}/>
<Divider style={dividerStyle}/>
<DrawerCell text='Movie' onPress={() => this.onChangingScreen(ScreenIndex.Movie)}/>
<DrawerCell text='Popular' onPress={() => this.onChangingScreen(ScreenIndex.Popular)}/>
Expand Down Expand Up @@ -112,6 +114,8 @@ export default class App extends Component {
Actions.Setting(); break;
case ScreenIndex.ToWatch:
Actions.ToWatch(); break;
case ScreenIndex.Schedule:
Actions.Schedule(); break;
}
this.refs['Drawer'].closeDrawer();
}
Expand Down
45 changes: 45 additions & 0 deletions AnimeGo/src/helper/core/AnimeSchedule.js
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('');
}
}
57 changes: 57 additions & 0 deletions AnimeGo/src/screen/Schedule.js
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};
32 changes: 32 additions & 0 deletions AnimeGo/src/screen/ScheduleStyles.js
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'
}
})
2 changes: 1 addition & 1 deletion AnimeGo/src/screen/ToWatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ToWatch extends Component {
</View>
</SmartTouchable>
)
}} automaticallyAdjustContentInsets={false}/>
}} automaticallyAdjustContentInsets={false} showsVerticalScrollIndicator={false}/>
<Button title='Remove all anime' color={RedColour} onPress={this.removeAllAnime}/>
</View>
);
Expand Down
3 changes: 2 additions & 1 deletion AnimeGo/src/screen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export * from './AnimeDetail';
export * from './WatchAnime';
export * from './SearchAnime';
export * from './SubCategory';
export * from './ToWatch';
export * from './ToWatch';
export * from './Schedule';
6 changes: 4 additions & 2 deletions AnimeGo/src/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -30,7 +30,8 @@ export const ScreenIndex = {
Popular: 3,
Genre: 4,
Setting: 5,
ToWatch: 6
ToWatch: 6,
Schedule: 7
}

export const MajorLink = {
Expand All @@ -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'
}

0 comments on commit 99d307a

Please sign in to comment.