예제 #1
0
 def handleRunQuery(self):
     self.myQuery = str(self.ui.mySearchLineEdit.text())
     if len(self.myQuery) > 0:
         self.ui.mySavePushButton.setEnabled(False)
         self.ui.myWatchPushButton.setEnabled(False)
         #create result depending on which linksite was checked
         if self.myAreResultsTvLinks:
             self.updateStatus("Searching TVLinks for %s" % (self.myQuery))
             self.createWebRequestThread(
                 self.updateSearchResults,
                 TVLinks.searchSite,
                 self.myQuery,
                 listWidget=self.ui.myResultsListWidget)
         else:
             self.updateStatus("Searching OneChannel for %s" %
                               (self.myQuery))
             if self.prefetchedKey is None:
                 print "not prefetched key"
                 searchMethod = OneChannel.searchSite
             else:
                 print "using prefetched key"
                 searchMethod = lambda query: OneChannel.searchSite(
                     query, self.prefetchedKey)
             self.createWebRequestThread(
                 self.updateSearchResults,
                 searchMethod,
                 self.myQuery,
                 listWidget=self.ui.myResultsListWidget)
예제 #2
0
 def handleRunQuery(self):
     self.myQuery = str(self.ui.mySearchLineEdit.text())
     if len(self.myQuery) > 0:
         self.ui.mySavePushButton.setEnabled(False)
         self.ui.myWatchPushButton.setEnabled(False)
         #create result depending on which linksite was checked
         if self.myAreResultsTvLinks:
             self.updateStatus("Searching TVLinks for %s" % (self.myQuery))
             self.createWebRequestThread(self.updateSearchResults, TVLinks.searchSite, self.myQuery, listWidget=self.ui.myResultsListWidget)
         else:
             self.updateStatus("Searching OneChannel for %s" % (self.myQuery))
             if self.prefetchedKey is None:
                 print "not prefetched key"
                 searchMethod = OneChannel.searchSite
             else:
                 print "using prefetched key"
                 searchMethod = lambda query: OneChannel.searchSite(query, self.prefetchedKey)
             self.createWebRequestThread(self.updateSearchResults, searchMethod, self.myQuery, listWidget=self.ui.myResultsListWidget)
예제 #3
0
def decide(show):
    #search onechannel for show
    oc_result = OneChannel.searchSite(show)[0]
    print oc_result
    #search tvlinks
    tl_result = TVLinks.searchSite(show)[0]
    print tl_result
    #instanciate both objects passing in the second part of the result tuple, the link
    oc = OneChannel(oc_result[1])
    tl = TVLinks(tl_result[1])
    all_sites = dict()
    #season is the last season of the show
    season = oc.getSeasons()[-1]
    #for all episodes in that season
    for episode in oc.getEpisodes(season):
        for type in oc.getHostSiteTypes(season, episode):
            if "daclips" in type:
                print season, episode, "onechannel"
            if type in all_sites:
                all_sites[type] = all_sites[type] + 1
            else:
                all_sites[type] = 1
            print all_sites
    season = tl.getSeasons()[-1]
    for episode in tl.getEpisodes(season):
        for type in tl.getHostSiteTypes(season, episode):
            if "daclips" in type:
                print season, episode, "tvlinks"
            if type in all_sites:
                all_sites[type] = all_sites[type] + 1
            else:
                all_sites[type] = 1
            print all_sites

    sorted_sites = sorted(all_sites.iteritems(), key=operator.itemgetter(1))
    sorted_sites.reverse()
    print sorted_sites
def decide(show):
    #search onechannel for show
    oc_result = OneChannel.searchSite(show)[0]
    print oc_result
    #search tvlinks
    tl_result = TVLinks.searchSite(show)[0]
    print tl_result
    #instanciate both objects passing in the second part of the result tuple, the link
    oc = OneChannel(oc_result[1])
    tl = TVLinks(tl_result[1])
    all_sites = dict()
    #season is the last season of the show
    season =oc.getSeasons()[-1]
    #for all episodes in that season
    for episode in oc.getEpisodes(season):
        for type in oc.getHostSiteTypes(season, episode):
            if "daclips" in type:
                print season, episode, "onechannel"
            if type in all_sites:
                all_sites[type] = all_sites[type] + 1
            else:
                all_sites[type] = 1
            print all_sites
    season =tl.getSeasons()[-1]
    for episode in tl.getEpisodes(season):
        for type in tl.getHostSiteTypes(season, episode):
            if "daclips" in type:
                print season, episode, "tvlinks"
            if type in all_sites:
                all_sites[type] = all_sites[type] + 1
            else:
                all_sites[type] = 1
            print all_sites
    
    sorted_sites =  sorted(all_sites.iteritems(), key=operator.itemgetter(1))
    sorted_sites.reverse()
    print sorted_sites
예제 #5
0
def main():

    parser = argparse.ArgumentParser(
                    description = 'Jankflix - A jankier way to watch things!')
    parser.add_argument('query', type = str, help = 'A show you want to watch',
                        nargs = "?")
    parser.add_argument('-s', dest = 'season', type = int, 
                        help = 'season to watch')
    parser.add_argument('-e', dest = 'episode', type = int, 
                        help = 'episode to watch')
    parser.add_argument('-c', dest = 'command', type = str, 
                        help = 'command to run when the video starts downloading')
    args = parser.parse_args()
    query = args.query
    season = args.season
    episode = args.episode
    command = args.command
    while True:
        if not query:
            query = raw_input("What show do you want to watch: ")
        search_result = OneChannel.searchSite(query)
        if len(search_result) == 0:
            print "Search did not return any results."
            query = None
        else:
            break
    for i in range(len(search_result)):
        title, link = search_result[i]
        print "%i : %s    (%s)" % (i, title, link)
    if len(search_result) > 1:
        selnum = get_int_input("Which one do you want to watch: ", 
                               0, len(search_result) - 1)
    else:
        print "Automatically choosing %s" % (search_result[0][0])
        selnum = 0

    title, link = search_result[selnum]
    print "Accessing show page"
    oc = OneChannel(link)
    seasons = oc.getSeasons()
    if season and season not in seasons:
        print "Season does not exist. Please choose another."
        season = None
    if not season:
        print "Seasons: ", str(seasons)[1:-1]
        season = get_int_input("Which season do you want to watch: ", 
                               int(min(seasons)), int(max(seasons)))
        #this assumes that between the min and max of the season numbers, 
        #it is completely filled. 
    print "Selecting season %d" % (season)

    episodes = oc.getEpisodes(season)

    names = oc.getEpisodeNames(season)

    if episode and episode not in episodes:
        print "Episode does not exist. Please choose another."
        episode = None
    if not episode:
        #TODO: this doesn't work. Need to cast array to int to run min on it. 
        for i in range(len(episodes)):
            print episodes[i], ":", names[i]
        episode = get_int_input("Which episode do you want to watch: ", 
                                int(min(episodes)), int(max(episodes)))
        #this assumes that between the min and max of the season numbers,
        #it is completely filled. 
    print "Selecting episode %d" % (episode)

    if not command :
        save_or_run = get_int_input(
                    "Do you want to (0) save or (1) run the episode: ", 0, 1)
        if save_or_run == 1:
            command = raw_input("Run with which program? (vlc): ")
            if command == "":
                command = "vlc"

    print "Getting host site"
    host_site = hostsitepicker.pickFromLinkSite(oc, season, episode)
    metadata = host_site.getMetadata()
    video_url = host_site.getVideo()
    filename = "%sS%sE%s.%s" % (query, str(season).zfill(2), 
                                str(episode).zfill(2), metadata["extension"])
    if command:
        processs, status = downloadmanager.start_downloads([(video_url, 
                                                             filename)])
        atexit.register(onexit, proc = processs[0], rmFile = filename)

        for i in range(30):
            if os.path.isfile(filename) and os.stat(filename).st_size > 1000:
                break
            else:
                time.sleep(.2)
        subprocess.call([command, filename])
        processs[0].terminate()
    else:
        processs, status = downloadmanager.start_downloads([(video_url, 
                                                             filename)])
        atexit.register(onexit, proc = processs[0])
        while processs[0].is_alive:
            print status[0].get(True)