-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make adjustment to .gitignore to upload lib files
- Loading branch information
1 parent
4c38b25
commit 7388bed
Showing
5 changed files
with
360 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ dist/ | |
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
|
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 @@ | ||
|
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,184 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
''' | ||
Genesis Add-on | ||
Copyright (C) 2015 Ratan Sunder Parai | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' | ||
|
||
from urllib import urlopen | ||
from BeautifulSoup import BeautifulSoup | ||
import requests | ||
from movieinfo import movieinfo | ||
from tmdbscraper import tmdbscraper | ||
import xbmcaddon | ||
import urllib | ||
import base64 | ||
|
||
class cinehub: | ||
|
||
# Perform login task and return request.session() object | ||
def login(self): | ||
|
||
# Login url | ||
loginUrl = "http://www.cinehub24.com/auth/login" | ||
|
||
myAddon = xbmcaddon.Addon() | ||
|
||
|
||
USERNAME = myAddon.getSetting("user_name") | ||
PASSWORD = myAddon.getSetting("user_password") | ||
|
||
|
||
|
||
if USERNAME == "" or PASSWORD == "" : | ||
myAddon.openSettings() | ||
|
||
session_requests = requests.session() | ||
|
||
# Create payload | ||
payload = { | ||
"user_name": USERNAME, | ||
"user_password": PASSWORD, | ||
'doLogin' : 'true', | ||
'submit' : 'Login' | ||
} | ||
|
||
# Perform login | ||
result = session_requests.post(loginUrl, data = payload, headers = dict(referer = loginUrl)) | ||
|
||
# check if login successfull | ||
# TODO | ||
|
||
return session_requests | ||
|
||
def getAllMovieList(self, session, page=1): | ||
URL = "http://www.cinehub24.com/net/section/english-movie/onlineContent.aspx/" + str(page) | ||
return self.getMovieList(session, URL, page) | ||
|
||
|
||
def getMovieList(self, session, URL, page = 1 ): | ||
# url for all movie list | ||
#URL = "http://www.cinehub24.com/net/section/english-movie/onlineContent.aspx/" + str(page) | ||
|
||
# get the html | ||
result = session.get(URL).content | ||
|
||
# make it ready for scraping | ||
soup = BeautifulSoup(result) | ||
|
||
# get movie list box | ||
movieBoxs = soup.findAll('div', attrs={'class': ['movie-list-hldr' , 'movie-list-hldr movielist-active']}) | ||
|
||
|
||
|
||
movielist = [] | ||
|
||
for movieBox in movieBoxs: | ||
# movie link | ||
movieLink = movieBox.find('div', attrs={'class' : 'movie-list-des'}).find('a') | ||
#print movieLink['href'] | ||
|
||
# get real movie links | ||
links = movieLink['href'] | ||
|
||
minfo = movieinfo() | ||
|
||
minfo.url = self.getVideoLink(session, links) | ||
|
||
#self.getVideoLink(session, links) | ||
|
||
if minfo.url : | ||
|
||
#movie title | ||
movieTitle = movieLink.find('b') | ||
#print movieTitle.string | ||
minfo.name = movieTitle.string | ||
|
||
movielist.append(minfo) | ||
|
||
|
||
return movielist | ||
|
||
def getVideoLink(self, session, URL): | ||
|
||
# get html file | ||
result = session.get(URL).content | ||
|
||
# create soup for scrapping | ||
soup = BeautifulSoup(result) | ||
|
||
linkTable = soup.find('table', attrs={'id': 'travel'}) | ||
|
||
tdId = 1 | ||
for i in range(1,5): | ||
try: | ||
tempName = linkTable.find('tbody').findAll('td')[tdId].find('b').string | ||
#print tempName | ||
|
||
# video file format mp4, avi and mkv and not containing sample | ||
if tempName.find('.mp4') != -1 or tempName.find('.avi') != -1 or tempName.find('.mkv') != -1 : | ||
if tempName.lower().find("sample") != -1 or tempName.lower().find("trailer") != -1 : | ||
pass | ||
else: | ||
tempVideoLink = linkTable.find('tbody').findAll('td')[tdId+3].find('a')['href'] | ||
result = session.get(tempVideoLink).content | ||
soup = BeautifulSoup(result) | ||
link = soup.find('div', attrs={'id': 'download_btn_r'}).find('a')['href'] | ||
return link.strip() | ||
else: | ||
tdId += 5 | ||
except: | ||
break | ||
|
||
|
||
def getMyMovieInfoList(self, page = 1): | ||
session = self.login() | ||
mymovieinfos = self.getAllMovieList(session, page) | ||
|
||
movieList = [] | ||
|
||
print "getting mymovieinfo..." | ||
for mymovieinfo in mymovieinfos: | ||
tScrap = tmdbscraper() | ||
mymovieinfo = tScrap.getMovieInfo(mymovieinfo) | ||
|
||
if mymovieinfo.imdbid: | ||
movieList.append(mymovieinfo) | ||
print mymovieinfo.title | ||
|
||
return movieList | ||
|
||
def searchMovies(self, searchTerm): | ||
searchTerm = searchTerm.strip() | ||
searchTerm = searchTerm.replace(" ", "+") | ||
URL = "http://www.cinehub24.com/search/{0}.aspx".format(searchTerm) | ||
|
||
session = self.login() | ||
mymovieinfos = self.getMovieList(session, URL, 1) | ||
|
||
movieList = [] | ||
for mymovieinfo in mymovieinfos: | ||
tScrap = tmdbscraper() | ||
mymovieinfo = tScrap.getMovieInfo(mymovieinfo) | ||
try: | ||
if mymovieinfo.imdbid: | ||
movieList.append(mymovieinfo) | ||
print mymovieinfo.title | ||
except: | ||
pass | ||
return movieList | ||
|
||
|
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,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
''' | ||
Genesis Add-on | ||
Copyright (C) 2015 Ratan Sunder Parai | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' | ||
|
||
class movieinfo: | ||
name = '' | ||
url = '' | ||
title = '' | ||
imdbid = '' | ||
genres = '' | ||
rating = '' | ||
runtime = '' | ||
tagline = '' | ||
totalVote = '' | ||
releaseDate = '' | ||
overview = '' | ||
posterImage = '' | ||
backdropImage = '' | ||
year = '' | ||
writer = '' | ||
director = '' | ||
castandrole = [] |
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,137 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
''' | ||
Genesis Add-on | ||
Copyright (C) 2015 Ratan Sunder Parai | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' | ||
|
||
from urllib import urlopen | ||
import json | ||
from movieinfo import movieinfo | ||
import re | ||
import urllib | ||
import base64 | ||
|
||
|
||
class tmdbscraper: | ||
|
||
API = base64.urlsafe_b64decode("N2U5MTYyMjM1NWFjZjI3NDM3ODQzNjcyMzRlOTFhODU=") | ||
|
||
def searchMovie(self, name, year=""): | ||
URL = "http://api.themoviedb.org/3/search/movie?api_key="+self.API+"&query=" + urllib.quote_plus(name) + "&year=" + str(year) | ||
result = urlopen(URL) | ||
moviejson = json.load(result) | ||
|
||
if moviejson['total_results'] == 0 : | ||
return 0 | ||
|
||
return moviejson['results'][0]['id'] | ||
|
||
def getMovieInfo(self, myMovieInfo): | ||
name = myMovieInfo.name | ||
|
||
# delete first bracket ( from name | ||
name = name.replace("(", "") | ||
name = name.replace(")", "") | ||
name = name.replace("[", "") | ||
name = name.replace("]", "") | ||
name = name.replace(".", " ") | ||
name = name.replace("_", " ") | ||
name = name.replace("{", "") | ||
name = name.replace("}", "") | ||
|
||
mgroup = re.split('[0-9]{4}', name) | ||
|
||
if mgroup : | ||
searchName = mgroup[0].strip() | ||
else: | ||
searchName = name | ||
|
||
m = re.search('[0-9]{4}', name) | ||
if m: | ||
searchYear = m.group(0) | ||
else: | ||
searchYear = "" | ||
|
||
# invoke search | ||
movieId = self.searchMovie(searchName, searchYear) | ||
|
||
print "tmdbid : " + str(movieId) | ||
|
||
if movieId == 0 : | ||
return myMovieInfo | ||
|
||
DETAIL_URL = "http://api.themoviedb.org/3/movie/"+ str(movieId) +"?api_key="+self.API | ||
|
||
CREDIT_URL = "http://api.themoviedb.org/3/movie/"+ str(movieId) + "/credits?api_key="+ self.API | ||
|
||
result = urlopen(DETAIL_URL) | ||
mJson = json.load(result) | ||
|
||
creditResult = urlopen(CREDIT_URL) | ||
cJson = json.load(creditResult) | ||
|
||
# encode strings to "utf-8" becuase kodi give error while showing unicode character | ||
myMovieInfo.title = mJson['title'].encode('utf-8') | ||
print "title = " + myMovieInfo.title | ||
myMovieInfo.imdbid = mJson['imdb_id'].encode('utf-8') | ||
myMovieInfo.totalVote = mJson['vote_average'] #rating | ||
myMovieInfo.rating = mJson['vote_count'] | ||
myMovieInfo.overview = mJson['overview'].encode('utf-8') | ||
myMovieInfo.runtime = mJson['runtime'] * 60 | ||
myMovieInfo.tagline = mJson['tagline'].encode('utf-8') #short description | ||
myMovieInfo.releaseDate = mJson['release_date'].encode('utf-8') | ||
tYear = mJson['release_date'].encode('utf-8') | ||
myMovieInfo.year = tYear[0:4] | ||
|
||
gList = [] | ||
for genre in mJson['genres'] : | ||
gList.append(genre['name'].encode('utf-8')) | ||
|
||
genres = ' / '.join(gList) | ||
|
||
myMovieInfo.genres = genres | ||
|
||
try: | ||
myMovieInfo.posterImage = "https://image.tmdb.org/t/p/w396" + mJson['poster_path'] | ||
except: | ||
pass | ||
try: | ||
myMovieInfo.backdropImage = "https://image.tmdb.org/t/p/w780" + mJson['backdrop_path'] | ||
except: | ||
pass | ||
|
||
try: | ||
myMovieInfo.director = cJson['crew'][0]['name'] | ||
myMovieInfo.writer = cJson['crew'][1]['name'] | ||
except: | ||
pass | ||
|
||
listCast = cJson['cast'] | ||
|
||
castName = [] | ||
castChar = [] | ||
for cast in listCast: | ||
name = cast['name'] | ||
castName.append(name) | ||
character = cast['character'] | ||
castChar.append(character) | ||
|
||
myMovieInfo.castandrole = zip(castName, castChar) | ||
|
||
return myMovieInfo | ||
|
||
|