Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Here is a snippet: <|code_start|> try: reg = _winreg.OpenKey(hkey, subkey) value = _winreg.QueryValue(reg, name) _winreg.CloseKey(reg) except _winreg.error: pass return value player = '"%s"' % get_registry_value('Software\\VideoLAN','VLC') or '' else: player = select_app("gmplayer", "gxine", "totem", "kaffeine", "vlc", "mplayer", "xine") if player: player = player + " %s" return player def get_imageviewer(): return sys.platform.startswith("win") and "browser" or select_app( "kuickshow", "display") + " %s" or "browser" def get_openfile(): if sys.platform == "darwin": return "open" else: return select_app("xdg-open", "exo-open", "gnome-open") or "" def get_sys_encoding(): if sys.platform.startswith("win"): return "utf-8" return locale.getpreferredencoding() <|code_end|> . Write the next line using the current file imports: import os, sys import socket import locale import _winreg import psyco import logging from lanshark.configuration import Boolean, Integer, String, StringList, Enum from lanshark import configuration and context from other files: # Path: lanshark/configuration.py # class Boolean(Key): # """Represents a bool""" # keytype = bool # def parse(self, value): # return (value.lower() != "false") # # class Integer(Key): # """Represents a int""" # keytype = int # # class String(Key): # """Represents a str""" # keytype = str # # class StringList(List, String): # "list of strings" # pass # # class Enum(String): # """Represents an enum""" # def __init__(self, default, values, doc): # """Creates new instance. `values` is a tuple of all valid enum # values""" # String.__init__(self, default, doc) # self.values = values # # def parse(self, value): # retval = String.parse(self, value) # if retval not in self.values: # raise ValueError('Invalid enum value %s' % retval) # return retval # # Path: lanshark/configuration.py # class Error(Exception): # class Config(observable.Observable): # class Key: # class String(Key): # class Integer(Key): # class Float(float): # class Boolean(Key): # class Enum(String): # class List: # class StringList(List, String): # class JSON(Key): # class TestConfig(Config): # def __init__(self, lineno, line, cause): # def __str__(self): # def __repr__(self): # def __init__(self): # def __setattr__(self, attr, value): # def load(self, f): # def _load(self, f): # def save(self, f): # def _save(self, f): # def __init__(self, default, doc): # def parse(self, value): # def dump(self, value): # def __repr__(self): # def parse(self, value): # def __init__(self, default, values, doc): # def parse(self, value): # def parse(self, value): # def parse(value): # def dump(self, value): # def dump(value): # def parse(self, value): # def dump(self, value): # def test(): , which may include functions, classes, or code. Output only the next line.
class Config(configuration.Config):
Given snippet: <|code_start|>#!/usr/bin/env python # vim: set fileencoding=utf-8 : """The lanshark lib encapsulates the client logic""" from __future__ import division from __future__ import with_statement __version__ = "1.0.0 Beta" copyright = \ """Lanshark %s - A P2P filesharing tool for local area networks Copyright (C) 2007 - 2008 Jonas Wagner 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. """ % __version__ logger = logging.getLogger('lanshark') <|code_end|> , continue by predicting the next line. Consider current file imports: import gc import logging import math import os import re import select, socket, subprocess, sys import time import urllib2 import simplejson from lanshark.config import config from lanshark.cache import cached from lanshark import network and context: # Path: lanshark/config.py # def in_pathlist(file, pathlist = os.environ.get("PATH").split(os.pathsep)): # def select_app(*apps): # def get_mediaplayer(): # def get_registry_value (subkey, name): # def get_imageviewer(): # def get_openfile(): # def get_sys_encoding(): # def __init__(self, path): # def debug(self): # def set_prefix(self, value): # def save(self, path=None): # class Config(configuration.Config): # LOG_LEVEL = Enum('CRITICAL', # ('CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'), # 'Sets the verbosity of logging output') # LOG_TARGET = String('-', # 'Target of logging output. Set to - to log stderr') # LOG_FORMAT = String('%(levelname)s:%(name)s:%(message)s', # 'Format of logging output. ' # 'See http://docs.python.org/lib/node422.html ' # 'for format description') # BROADCAST_IP = String("255.255.255.255", # "IP to use for udp broadcasts") # PORT = Integer(31337, "Port to use for both UDP and TCP") # CLIENT_PORT = Integer(31338, "Port for the clients udp sockets") # SEARCH_TIMEOUT = Integer(5, # "Time to wait for search results in seconds") # DISCOVER_TIMEOUT = Integer(5, # "Time to wait for new hosts to answer in seconds") # DISCOVER_INTERVAL = Integer(60, # "Interval to search for new computers in seconds") # NETWORK_NAME = String("HELO", # "Word to use for discovery, might act as simple password") # CACHE_TIMEOUT = Integer(600, "HTTP cache time to live") # SHARE_PATH = String("", "Path to the files you want to share") # INCOMING_PATH = String("", "Path to store the downloaded files") # MAX_SEARCH_RESULTS = Integer(128, # "Maximal number of search results per peer") # FOLDER_IMAGES = StringList([r"\.?folder\.(png|jpg|gif|img)$", # r"cover\.(png|jpg|gif)$", # r"(cover\-)?front\.(png|jpg|gif)$", # r"cover.*?\.(png|jpg|gif)$", # r"albumart.*?large\.jpg$", # r"albumart.*?\.jpg"], # "regexps to match the folder images/covers") # MAX_IMAGE_SIZE = Integer(250000, # "Maximal size of preview images/covers to use") # DAEMON_IN_GUI = Boolean(True, # "Integrates daemon in the gui process") # RESOLVE_HOSTS = Boolean(False, "Resolve hostnames") # INDEX_INTERVAL = Integer(3600, # "Interval to update the fileindex in seconds") # GUI_ICON_SIZE = Integer(48, "Icon size in the gtkui") # PID_FILE = String(os.path.join("$configdir", "lanshark.pid"), # "Location of the pid file") # SOCKET_TIMEOUT = Integer(5000, "The timeout of tcp sockets in ms") # VIDEO_PLAYER = String(get_mediaplayer(), # "Command to play video files %s gets replaced with " # "the url to the video") # AUDIO_PLAYER = String(get_mediaplayer(), # "Command to play audio files %s gets replaced with" # "the url to the audio file ") # IMAGE_VIEWER = String(get_imageviewer(), # "Command to view images files %s gets replaced with" # "the url to the image ") # DISABLE_WEBINTERFACE = Boolean(False, "Do not show html interface") # FS_ENCODING = String(sys.getfilesystemencoding(), "Filesystem encoding") # SYS_ENCODING = String(get_sys_encoding(), 'System Encoding') # HOSTNAME = String(socket.gethostname(), "The name of your host/share") # DOWNLOAD_RELPATH = Boolean(True, "Use relative paths for downloads" # "instead of absolute ones") # INVISIBLE = Boolean(False, "Do not answer to discovery or search requests") # STATUSICON = Boolean(True, "Show icon in statusbar") # STATICHOSTS = StringList([], "Static peer entries for networks where udp" # "broadcasts are not avaible. " # "Exmaple: example.com:31337, 192.168.1.2:31337") # HIDDEN_FILES = StringList([r"\..*", r"Thumbs\.db"], # "Regexps to match hidden files") # PSYCO = Boolean(False, "Enable psyco JIT") # OPENFILE = String(get_openfile(), "The application used to start/open files") # LANGUAGES = [locale.getdefaultlocale()[0] or "en_US", "en_US"] # WEBSITE = "http://lanshark.29a.ch/" # VERSION = Integer(6, "Version of the config file") # DOWNLOAD_BS = 65536 # # Path: lanshark/cache.py # def cached(timeout=600, max_items=128, stats=False): # """cache decorator with variable timeout and maximal items""" # return lambda func: _Cached(func, timeout, max_items, stats) # # Path: lanshark/network.py # def broadcast_dgram_socket(port): which might include code, classes, or functions. Output only the next line.
socket.getaddrinfo = cached(config.CACHE_TIMEOUT, stats=config.debug)(
Using the snippet: <|code_start|>#!/usr/bin/env python # vim: set fileencoding=utf-8 : """The lanshark lib encapsulates the client logic""" from __future__ import division from __future__ import with_statement __version__ = "1.0.0 Beta" copyright = \ """Lanshark %s - A P2P filesharing tool for local area networks Copyright (C) 2007 - 2008 Jonas Wagner 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. """ % __version__ logger = logging.getLogger('lanshark') <|code_end|> , determine the next line of code. You have imports: import gc import logging import math import os import re import select, socket, subprocess, sys import time import urllib2 import simplejson from lanshark.config import config from lanshark.cache import cached from lanshark import network and context (class names, function names, or code) available: # Path: lanshark/config.py # def in_pathlist(file, pathlist = os.environ.get("PATH").split(os.pathsep)): # def select_app(*apps): # def get_mediaplayer(): # def get_registry_value (subkey, name): # def get_imageviewer(): # def get_openfile(): # def get_sys_encoding(): # def __init__(self, path): # def debug(self): # def set_prefix(self, value): # def save(self, path=None): # class Config(configuration.Config): # LOG_LEVEL = Enum('CRITICAL', # ('CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'), # 'Sets the verbosity of logging output') # LOG_TARGET = String('-', # 'Target of logging output. Set to - to log stderr') # LOG_FORMAT = String('%(levelname)s:%(name)s:%(message)s', # 'Format of logging output. ' # 'See http://docs.python.org/lib/node422.html ' # 'for format description') # BROADCAST_IP = String("255.255.255.255", # "IP to use for udp broadcasts") # PORT = Integer(31337, "Port to use for both UDP and TCP") # CLIENT_PORT = Integer(31338, "Port for the clients udp sockets") # SEARCH_TIMEOUT = Integer(5, # "Time to wait for search results in seconds") # DISCOVER_TIMEOUT = Integer(5, # "Time to wait for new hosts to answer in seconds") # DISCOVER_INTERVAL = Integer(60, # "Interval to search for new computers in seconds") # NETWORK_NAME = String("HELO", # "Word to use for discovery, might act as simple password") # CACHE_TIMEOUT = Integer(600, "HTTP cache time to live") # SHARE_PATH = String("", "Path to the files you want to share") # INCOMING_PATH = String("", "Path to store the downloaded files") # MAX_SEARCH_RESULTS = Integer(128, # "Maximal number of search results per peer") # FOLDER_IMAGES = StringList([r"\.?folder\.(png|jpg|gif|img)$", # r"cover\.(png|jpg|gif)$", # r"(cover\-)?front\.(png|jpg|gif)$", # r"cover.*?\.(png|jpg|gif)$", # r"albumart.*?large\.jpg$", # r"albumart.*?\.jpg"], # "regexps to match the folder images/covers") # MAX_IMAGE_SIZE = Integer(250000, # "Maximal size of preview images/covers to use") # DAEMON_IN_GUI = Boolean(True, # "Integrates daemon in the gui process") # RESOLVE_HOSTS = Boolean(False, "Resolve hostnames") # INDEX_INTERVAL = Integer(3600, # "Interval to update the fileindex in seconds") # GUI_ICON_SIZE = Integer(48, "Icon size in the gtkui") # PID_FILE = String(os.path.join("$configdir", "lanshark.pid"), # "Location of the pid file") # SOCKET_TIMEOUT = Integer(5000, "The timeout of tcp sockets in ms") # VIDEO_PLAYER = String(get_mediaplayer(), # "Command to play video files %s gets replaced with " # "the url to the video") # AUDIO_PLAYER = String(get_mediaplayer(), # "Command to play audio files %s gets replaced with" # "the url to the audio file ") # IMAGE_VIEWER = String(get_imageviewer(), # "Command to view images files %s gets replaced with" # "the url to the image ") # DISABLE_WEBINTERFACE = Boolean(False, "Do not show html interface") # FS_ENCODING = String(sys.getfilesystemencoding(), "Filesystem encoding") # SYS_ENCODING = String(get_sys_encoding(), 'System Encoding') # HOSTNAME = String(socket.gethostname(), "The name of your host/share") # DOWNLOAD_RELPATH = Boolean(True, "Use relative paths for downloads" # "instead of absolute ones") # INVISIBLE = Boolean(False, "Do not answer to discovery or search requests") # STATUSICON = Boolean(True, "Show icon in statusbar") # STATICHOSTS = StringList([], "Static peer entries for networks where udp" # "broadcasts are not avaible. " # "Exmaple: example.com:31337, 192.168.1.2:31337") # HIDDEN_FILES = StringList([r"\..*", r"Thumbs\.db"], # "Regexps to match hidden files") # PSYCO = Boolean(False, "Enable psyco JIT") # OPENFILE = String(get_openfile(), "The application used to start/open files") # LANGUAGES = [locale.getdefaultlocale()[0] or "en_US", "en_US"] # WEBSITE = "http://lanshark.29a.ch/" # VERSION = Integer(6, "Version of the config file") # DOWNLOAD_BS = 65536 # # Path: lanshark/cache.py # def cached(timeout=600, max_items=128, stats=False): # """cache decorator with variable timeout and maximal items""" # return lambda func: _Cached(func, timeout, max_items, stats) # # Path: lanshark/network.py # def broadcast_dgram_socket(port): . Output only the next line.
socket.getaddrinfo = cached(config.CACHE_TIMEOUT, stats=config.debug)(
Predict the next line after this snippet: <|code_start|> else: maxwait = timeout - time.time() + start rwxlist = select.select((sock, ), (), (), maxwait) if rwxlist[0]: try: data, addr = sock.recvfrom(1024) logger.debug("recv %r %r", addr, data) except socket.error, e: # handle udp instability logger.debug("socket.error in recv(): %r", e) else: yield (data, addr) continue if async: yield None break def resolve(addr): """resolve host if enabled in config""" if config.RESOLVE_HOSTS: try: return socket.gethostbyaddr(addr)[0] except socket.herror, e: logger.debug(e) return addr def discover(async=False): """Discover other hosts in the network""" for item in config.STATICHOSTS: url = "http://%s/" % item yield (item, url) <|code_end|> using the current file's imports: import gc import logging import math import os import re import select, socket, subprocess, sys import time import urllib2 import simplejson from lanshark.config import config from lanshark.cache import cached from lanshark import network and any relevant context from other files: # Path: lanshark/config.py # def in_pathlist(file, pathlist = os.environ.get("PATH").split(os.pathsep)): # def select_app(*apps): # def get_mediaplayer(): # def get_registry_value (subkey, name): # def get_imageviewer(): # def get_openfile(): # def get_sys_encoding(): # def __init__(self, path): # def debug(self): # def set_prefix(self, value): # def save(self, path=None): # class Config(configuration.Config): # LOG_LEVEL = Enum('CRITICAL', # ('CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'), # 'Sets the verbosity of logging output') # LOG_TARGET = String('-', # 'Target of logging output. Set to - to log stderr') # LOG_FORMAT = String('%(levelname)s:%(name)s:%(message)s', # 'Format of logging output. ' # 'See http://docs.python.org/lib/node422.html ' # 'for format description') # BROADCAST_IP = String("255.255.255.255", # "IP to use for udp broadcasts") # PORT = Integer(31337, "Port to use for both UDP and TCP") # CLIENT_PORT = Integer(31338, "Port for the clients udp sockets") # SEARCH_TIMEOUT = Integer(5, # "Time to wait for search results in seconds") # DISCOVER_TIMEOUT = Integer(5, # "Time to wait for new hosts to answer in seconds") # DISCOVER_INTERVAL = Integer(60, # "Interval to search for new computers in seconds") # NETWORK_NAME = String("HELO", # "Word to use for discovery, might act as simple password") # CACHE_TIMEOUT = Integer(600, "HTTP cache time to live") # SHARE_PATH = String("", "Path to the files you want to share") # INCOMING_PATH = String("", "Path to store the downloaded files") # MAX_SEARCH_RESULTS = Integer(128, # "Maximal number of search results per peer") # FOLDER_IMAGES = StringList([r"\.?folder\.(png|jpg|gif|img)$", # r"cover\.(png|jpg|gif)$", # r"(cover\-)?front\.(png|jpg|gif)$", # r"cover.*?\.(png|jpg|gif)$", # r"albumart.*?large\.jpg$", # r"albumart.*?\.jpg"], # "regexps to match the folder images/covers") # MAX_IMAGE_SIZE = Integer(250000, # "Maximal size of preview images/covers to use") # DAEMON_IN_GUI = Boolean(True, # "Integrates daemon in the gui process") # RESOLVE_HOSTS = Boolean(False, "Resolve hostnames") # INDEX_INTERVAL = Integer(3600, # "Interval to update the fileindex in seconds") # GUI_ICON_SIZE = Integer(48, "Icon size in the gtkui") # PID_FILE = String(os.path.join("$configdir", "lanshark.pid"), # "Location of the pid file") # SOCKET_TIMEOUT = Integer(5000, "The timeout of tcp sockets in ms") # VIDEO_PLAYER = String(get_mediaplayer(), # "Command to play video files %s gets replaced with " # "the url to the video") # AUDIO_PLAYER = String(get_mediaplayer(), # "Command to play audio files %s gets replaced with" # "the url to the audio file ") # IMAGE_VIEWER = String(get_imageviewer(), # "Command to view images files %s gets replaced with" # "the url to the image ") # DISABLE_WEBINTERFACE = Boolean(False, "Do not show html interface") # FS_ENCODING = String(sys.getfilesystemencoding(), "Filesystem encoding") # SYS_ENCODING = String(get_sys_encoding(), 'System Encoding') # HOSTNAME = String(socket.gethostname(), "The name of your host/share") # DOWNLOAD_RELPATH = Boolean(True, "Use relative paths for downloads" # "instead of absolute ones") # INVISIBLE = Boolean(False, "Do not answer to discovery or search requests") # STATUSICON = Boolean(True, "Show icon in statusbar") # STATICHOSTS = StringList([], "Static peer entries for networks where udp" # "broadcasts are not avaible. " # "Exmaple: example.com:31337, 192.168.1.2:31337") # HIDDEN_FILES = StringList([r"\..*", r"Thumbs\.db"], # "Regexps to match hidden files") # PSYCO = Boolean(False, "Enable psyco JIT") # OPENFILE = String(get_openfile(), "The application used to start/open files") # LANGUAGES = [locale.getdefaultlocale()[0] or "en_US", "en_US"] # WEBSITE = "http://lanshark.29a.ch/" # VERSION = Integer(6, "Version of the config file") # DOWNLOAD_BS = 65536 # # Path: lanshark/cache.py # def cached(timeout=600, max_items=128, stats=False): # """cache decorator with variable timeout and maximal items""" # return lambda func: _Cached(func, timeout, max_items, stats) # # Path: lanshark/network.py # def broadcast_dgram_socket(port): . Output only the next line.
s = network.broadcast_dgram_socket(config.CLIENT_PORT)
Using the snippet: <|code_start|>class MyConfig(Config): n = Integer(10, "Some doc") foobar = String("bar", "Some more doc") trve = IsTrve(True, "Even more doc") config = MyConfig() config.load("foo.conf") config.n = 0x29a config.save() """ from __future__ import with_statement class Error(Exception): """Raised when an error occures while parsing the confiuration file""" def __init__(self, lineno, line, cause): self.line = line self.lineno = lineno self.__cause__ = cause self.message = "Error while parsing configuration on line %i: '%s'\n"\ "%s" % (lineno, line, str(cause)) def __str__(self): return self.message def __repr__(self): return self.message # TODO: Add some kind of onchange events <|code_end|> , determine the next line of code. You have imports: import os import simplejson from lanshark import observable from StringIO import StringIO and context (class names, function names, or code) available: # Path: lanshark/observable.py # class Observable(object): # def __init__(self): # def connect(self, event, callback): # def disconnect(self, event, callback): # def notify(self, event, *args): # def test(): # def callback(bar): . Output only the next line.
class Config(observable.Observable):
Continue the code snippet: <|code_start|># >>> "gender": "female", # >>> "videos_count_all": "8" # >>> } # >>> }, # >>> ... etc # >>> ] # >>> } # # /categories # >>> { # >>> "categories": [ # >>> { "id": "97", "category": "italian" }, # >>> { "id": "105", "category": "60fps-1" }, # >>> { "id": "252", "category": "amateur-gay" } # >>> ] # >>> } # # # # ITEMS_PER_PAGE = 30 ST_HOME = 0 ST_SEARCH = 1 ST_CATEGORIES = 2 # ST_PORNSTARS = 3 ST_VIDEO_LIST = 4 ST_PLAY = 69 <|code_end|> . Use current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Predict the next line for this snippet: <|code_start|> # the first page, show fixed categories if STATE == ST_HOME: url = 'http://it.pornhub.com/random' item_add(ST_PLAY, _('Play a random video'), url, icon='icon/play') item_add(ST_SEARCH, _('Search videos'), 'search', action=ACT_SEARCH) url = API_BASE + '/categories' item_add(ST_CATEGORIES, _('Categories'), url, action=ACT_FOLDER) url = API_BASE + '/search?ordering=newest&page=1' item_add(ST_VIDEO_LIST, _('Recently added'), url, action=ACT_FOLDER) url = API_BASE + '/search?ordering=mostviewed&period=alltime&page=1' item_add(ST_VIDEO_LIST, _('Most viewed'), url, action=ACT_FOLDER) url = API_BASE + '/search?ordering=rating&period=alltime&page=1' item_add(ST_VIDEO_LIST, _('Top rated'), url, action=ACT_FOLDER) # url = API_BASE + '/stars_detailed' # item_add(ST_PORNSTARS, _('All pornstars'), url, action=ACT_FOLDER) # search query from virtual keyboard elif STATE == ST_SEARCH: url = API_BASE + '/search?' + \ url_encode({'search': URL, 'thumbsize': 'large'}) <|code_end|> with the help of current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
data = fetch_url(url, parser='json')
Based on the snippet: <|code_start|> # videos list elif STATE == ST_VIDEO_LIST: data = fetch_url(URL, parser='json') try: build_video_list(URL, data['videos']) except KeyError: # last page probably reached pass # categories list elif STATE == ST_CATEGORIES: data = fetch_url(URL, parser='json') for cat in data['categories']: url = API_BASE + '/search?' + url_encode({'category': cat['category']}) item_add(ST_VIDEO_LIST, cat['category'], url + '&page=1') # pornstars list # elif STATE == ST_PORNSTARS: # data = fetch_url(URL, parser='json') # for star in data['stars']: # star = star['star'] # url = star['star_url'] + '&page=1' ## THIS IS WRONG (or must be scraped) # title = '{} ({} vids)'.format(star['star_name'], star['videos_count_all']) # item_add(ST_VIDEO_LIST, title, url, poster=star['star_thumb']) # play (using youtube-dl) elif STATE == ST_PLAY: url = call_ydl(URL) <|code_end|> , predict the immediate next line with the help of imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(url) if url else report_error('Video not found')
Predict the next line for this snippet: <|code_start|>ST_PLAY = 69 STATE, URL = state_get() def build_video_list(url, videos): for video in videos: title = video['title'] or 'Untitled video' likes = int(float(video['ratings']) / 100 * float(video['rating'])) actors = [p['pornstar_name'] for p in video['pornstars']] cats = [c['category'] for c in video['categories']] tags = [t['tag_name'] for t in video['tags']] info = '<title>{}</title> <small>{}</small><br>' \ '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.0f}%</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>{}:</name> {}<br>' \ '<name>{}:</name> {}<br>' \ '<name>{}:</name> {}<br>' \ .format( title, video['duration'], _('uploaded'), relative_date(video['publish_date']), video['views'], ngettext('view', 'views', int(video['views'])), _('rated'), float(video['rating']), likes, ngettext('like', 'likes', likes), _('Actors'), ', '.join(actors), _('Categories'), ', '.join(cats), _('Tags'), ', '.join(tags), ) <|code_end|> with the help of current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info)
Continue the code snippet: <|code_start|> # videos list elif STATE == ST_VIDEO_LIST: data = fetch_url(URL, parser='json') try: build_video_list(URL, data['videos']) except KeyError: # last page probably reached pass # categories list elif STATE == ST_CATEGORIES: data = fetch_url(URL, parser='json') for cat in data['categories']: url = API_BASE + '/search?' + url_encode({'category': cat['category']}) item_add(ST_VIDEO_LIST, cat['category'], url + '&page=1') # pornstars list # elif STATE == ST_PORNSTARS: # data = fetch_url(URL, parser='json') # for star in data['stars']: # star = star['star'] # url = star['star_url'] + '&page=1' ## THIS IS WRONG (or must be scraped) # title = '{} ({} vids)'.format(star['star_name'], star['videos_count_all']) # item_add(ST_VIDEO_LIST, title, url, poster=star['star_thumb']) # play (using youtube-dl) elif STATE == ST_PLAY: <|code_end|> . Use current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
url = call_ydl(URL)
Predict the next line after this snippet: <|code_start|> # videos list elif STATE == ST_VIDEO_LIST: data = fetch_url(URL, parser='json') try: build_video_list(URL, data['videos']) except KeyError: # last page probably reached pass # categories list elif STATE == ST_CATEGORIES: data = fetch_url(URL, parser='json') for cat in data['categories']: url = API_BASE + '/search?' + url_encode({'category': cat['category']}) item_add(ST_VIDEO_LIST, cat['category'], url + '&page=1') # pornstars list # elif STATE == ST_PORNSTARS: # data = fetch_url(URL, parser='json') # for star in data['stars']: # star = star['star'] # url = star['star_url'] + '&page=1' ## THIS IS WRONG (or must be scraped) # title = '{} ({} vids)'.format(star['star_name'], star['videos_count_all']) # item_add(ST_VIDEO_LIST, title, url, poster=star['star_thumb']) # play (using youtube-dl) elif STATE == ST_PLAY: url = call_ydl(URL) <|code_end|> using the current file's imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(url) if url else report_error('Video not found')
Given the code snippet: <|code_start|> # ITEMS_PER_PAGE = 30 ST_HOME = 0 ST_SEARCH = 1 ST_CATEGORIES = 2 # ST_PORNSTARS = 3 ST_VIDEO_LIST = 4 ST_PLAY = 69 STATE, URL = state_get() def build_video_list(url, videos): for video in videos: title = video['title'] or 'Untitled video' likes = int(float(video['ratings']) / 100 * float(video['rating'])) actors = [p['pornstar_name'] for p in video['pornstars']] cats = [c['category'] for c in video['categories']] tags = [t['tag_name'] for t in video['tags']] info = '<title>{}</title> <small>{}</small><br>' \ '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.0f}%</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>{}:</name> {}<br>' \ '<name>{}:</name> {}<br>' \ '<name>{}:</name> {}<br>' \ .format( title, video['duration'], <|code_end|> , generate the next line using the imports in this file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
_('uploaded'), relative_date(video['publish_date']),
Next line prediction: <|code_start|> item_add(next_state, _('More items...'), url, action=ACT_MORE) # the first page, show fixed categories if STATE == ST_HOME: url = 'http://it.pornhub.com/random' item_add(ST_PLAY, _('Play a random video'), url, icon='icon/play') item_add(ST_SEARCH, _('Search videos'), 'search', action=ACT_SEARCH) url = API_BASE + '/categories' item_add(ST_CATEGORIES, _('Categories'), url, action=ACT_FOLDER) url = API_BASE + '/search?ordering=newest&page=1' item_add(ST_VIDEO_LIST, _('Recently added'), url, action=ACT_FOLDER) url = API_BASE + '/search?ordering=mostviewed&period=alltime&page=1' item_add(ST_VIDEO_LIST, _('Most viewed'), url, action=ACT_FOLDER) url = API_BASE + '/search?ordering=rating&period=alltime&page=1' item_add(ST_VIDEO_LIST, _('Top rated'), url, action=ACT_FOLDER) # url = API_BASE + '/stars_detailed' # item_add(ST_PORNSTARS, _('All pornstars'), url, action=ACT_FOLDER) # search query from virtual keyboard elif STATE == ST_SEARCH: url = API_BASE + '/search?' + \ <|code_end|> . Use current file imports: (from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
url_encode({'search': URL, 'thumbsize': 'large'})
Using the snippet: <|code_start|> likes, ngettext('like', 'likes', likes), _('Actors'), ', '.join(actors), _('Categories'), ', '.join(cats), _('Tags'), ', '.join(tags), ) item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info) if len(videos) == 30: build_next_page_item(url, ST_VIDEO_LIST) def build_next_page_item(url, next_state): # NOTE: this assume 'page=X' is ALWAYS the last param!! don't forget it! # num_pages = int(total / ITEMS_PER_PAGE) + 1 url, cur_page = url.split('page=') next_page = int(cur_page) + 1 # if next_page <= num_pages: url += 'page=' + str(next_page) item_add(next_state, _('More items...'), url, action=ACT_MORE) # the first page, show fixed categories if STATE == ST_HOME: url = 'http://it.pornhub.com/random' item_add(ST_PLAY, _('Play a random video'), url, icon='icon/play') item_add(ST_SEARCH, _('Search videos'), 'search', action=ACT_SEARCH) url = API_BASE + '/categories' <|code_end|> , determine the next line of code. You have imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_CATEGORIES, _('Categories'), url, action=ACT_FOLDER)
Based on the snippet: <|code_start|> '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.0f}%</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>{}:</name> {}<br>' \ '<name>{}:</name> {}<br>' \ '<name>{}:</name> {}<br>' \ .format( title, video['duration'], _('uploaded'), relative_date(video['publish_date']), video['views'], ngettext('view', 'views', int(video['views'])), _('rated'), float(video['rating']), likes, ngettext('like', 'likes', likes), _('Actors'), ', '.join(actors), _('Categories'), ', '.join(cats), _('Tags'), ', '.join(tags), ) item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info) if len(videos) == 30: build_next_page_item(url, ST_VIDEO_LIST) def build_next_page_item(url, next_state): # NOTE: this assume 'page=X' is ALWAYS the last param!! don't forget it! # num_pages = int(total / ITEMS_PER_PAGE) + 1 url, cur_page = url.split('page=') next_page = int(cur_page) + 1 # if next_page <= num_pages: url += 'page=' + str(next_page) <|code_end|> , predict the immediate next line with the help of imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(next_state, _('More items...'), url, action=ACT_MORE)
Next line prediction: <|code_start|> _('uploaded'), relative_date(video['publish_date']), video['views'], ngettext('view', 'views', int(video['views'])), _('rated'), float(video['rating']), likes, ngettext('like', 'likes', likes), _('Actors'), ', '.join(actors), _('Categories'), ', '.join(cats), _('Tags'), ', '.join(tags), ) item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info) if len(videos) == 30: build_next_page_item(url, ST_VIDEO_LIST) def build_next_page_item(url, next_state): # NOTE: this assume 'page=X' is ALWAYS the last param!! don't forget it! # num_pages = int(total / ITEMS_PER_PAGE) + 1 url, cur_page = url.split('page=') next_page = int(cur_page) + 1 # if next_page <= num_pages: url += 'page=' + str(next_page) item_add(next_state, _('More items...'), url, action=ACT_MORE) # the first page, show fixed categories if STATE == ST_HOME: url = 'http://it.pornhub.com/random' item_add(ST_PLAY, _('Play a random video'), url, icon='icon/play') <|code_end|> . Use current file imports: (from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_SEARCH, _('Search videos'), 'search', action=ACT_SEARCH)
Given snippet: <|code_start|> def __init__(self, *args): super().__init__(*args) self._exe = None self._starting = False def generate_item(self, item): if super().generate_item(item) is False: return False if not self._exe: self._slave_process_start() return True if not self._starting: self._send_request() return True def kill(self): if self._exe: self._exe.on_del_event_del(self._slave_died_cb) self._exe.kill() self._exe.delete() self._exe = None self._starting = False def _slave_process_start(self): DBG('starting slave') self._starting = True <|code_end|> , continue by predicting the next line. Consider current file imports: import os from collections import OrderedDict from efl import ecore from epymc import utils from epymc import ini and context: # Path: epymc/utils.py # XDG_CONFIG_HOME = '' # XDG_CACHE_HOME = '' # def LOG(*args): # def DBG(msg): # def iso639_1_to_3(iso1): # def iso639_1_to_5(iso1): # def is_py3(): # def is_py2(): # def get_resource_file(res_type, res_name, default=None): # def get_available_themes(): # def in_use_theme_file_set(theme_file): # def url2path(url): # def hum_size(bites): # def seconds_to_duration(seconds, hours=False): # def splitpath(path): # def ensure_file_not_exists(fullpath): # def md5(txt): # def user_name(): # def natural_sort(li): # def natural_cmp(a, b): # def grab_files(folders, show_hidden=False, recursive=True): # def download_url_async(url, dest='tmp', min_size=0, # complete_cb=None, progress_cb=None, # urlencode=True, *args, **kargs): # def _cb_download_complete(dest, status, dwl_data, *args, **kargs): # def _cb_download_progress(dest, dltotal, dlnow, uptotal, upnow, dwl_data, *args, **kargs): # def download_abort(dwl_handler): # def http_error_code_to_str(code): # def distance_between_point_and_segment(point, segment_p1, segment_p2, real=False): # def __new__(cls, *args, **kwargs): # def __init__(self, cmd, grab_output=False, done_cb=None, *args, **kargs): # def data_cb(self, exe, event): # def del_cb(self, exe, event): # def __init__(self, url, done_cb=None, prog_cb=None, headers=None, **kargs): # def _complete_cb(self, event): # def _data_cb(self, event): # class Singleton(object): # class EmcExec(object): # class EmcUrl(ecore_con.Url): # # Path: epymc/ini.py # def read_from_files(files): # def write_to_file(file): # def setup_defaults(): # def add_section(section): # def has_section(section): # def has_option(section, option): # def has_options(options): # def get_options(section): # def get(section, option, default_value=None): # def get_string_list(section, option, separator=' '): # def get_int(section, option): # def get_float(section, option): # def get_bool(section, option): # def get_string(section, option): # def set(section, option, value): # def set_string_list(section, option, values, separator=' '): # def remove_option(section, option): which might include code, classes, or functions. Output only the next line.
self._exe = ecore.Exe('epymc_thumbnailer "%s"' % utils.in_use_theme_file,
Continue the code snippet: <|code_start|># This file is part of EpyMC, an EFL based Media Center written in Python. # # 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/>. def DBG(*args): print('THUMBNAILER:', *args) pass def ERR(*args): print('THUMBNAILER ERROR:', *args) def init(): # setup default config values <|code_end|> . Use current file imports: import os from collections import OrderedDict from efl import ecore from epymc import utils from epymc import ini and context (classes, functions, or code) from other files: # Path: epymc/utils.py # XDG_CONFIG_HOME = '' # XDG_CACHE_HOME = '' # def LOG(*args): # def DBG(msg): # def iso639_1_to_3(iso1): # def iso639_1_to_5(iso1): # def is_py3(): # def is_py2(): # def get_resource_file(res_type, res_name, default=None): # def get_available_themes(): # def in_use_theme_file_set(theme_file): # def url2path(url): # def hum_size(bites): # def seconds_to_duration(seconds, hours=False): # def splitpath(path): # def ensure_file_not_exists(fullpath): # def md5(txt): # def user_name(): # def natural_sort(li): # def natural_cmp(a, b): # def grab_files(folders, show_hidden=False, recursive=True): # def download_url_async(url, dest='tmp', min_size=0, # complete_cb=None, progress_cb=None, # urlencode=True, *args, **kargs): # def _cb_download_complete(dest, status, dwl_data, *args, **kargs): # def _cb_download_progress(dest, dltotal, dlnow, uptotal, upnow, dwl_data, *args, **kargs): # def download_abort(dwl_handler): # def http_error_code_to_str(code): # def distance_between_point_and_segment(point, segment_p1, segment_p2, real=False): # def __new__(cls, *args, **kwargs): # def __init__(self, cmd, grab_output=False, done_cb=None, *args, **kargs): # def data_cb(self, exe, event): # def del_cb(self, exe, event): # def __init__(self, url, done_cb=None, prog_cb=None, headers=None, **kargs): # def _complete_cb(self, event): # def _data_cb(self, event): # class Singleton(object): # class EmcExec(object): # class EmcUrl(ecore_con.Url): # # Path: epymc/ini.py # def read_from_files(files): # def write_to_file(file): # def setup_defaults(): # def add_section(section): # def has_section(section): # def has_option(section, option): # def has_options(options): # def get_options(section): # def get(section, option, default_value=None): # def get_string_list(section, option, separator=' '): # def get_int(section, option): # def get_float(section, option): # def get_bool(section, option): # def get_string(section, option): # def set(section, option, value): # def set_string_list(section, option, values, separator=' '): # def remove_option(section, option): . Output only the next line.
ini.add_section('thumbnailer')
Predict the next line for this snippet: <|code_start|> self.go() def _folder_insert_sorted(self, path): s = self.first_item # search ordered position only between folders while s and s.data.get('isfolder', False) is True and \ utils.natural_cmp(s.data['path'], path) < 0: s = s.next # insert the new folder before search or before the first file name = os.path.basename(path) icon = gui.load_icon('icon/folder') it = self.item_insert_before(s, name, icon) if s else \ self.item_append(name, icon) it.data['path'] = path it.data['isfolder'] = True self.go() def _path_remove(self, path): item = self.first_item while item and item.data.get('path') != path: item = item.next if item and item.selected: to_sel = item.prev or item.next to_sel.selected = True if item: item.delete() <|code_end|> with the help of current file imports: import os import threading import queue import epymc.mainmenu as mainmenu import epymc.input_events as input_events import epymc.storage as storage import epymc.utils as utils import epymc.gui as gui import epymc.ini as ini from efl import ecore from efl.elementary.list import List from epymc.modules import EmcModule from epymc.gui import EXPAND_BOTH, EXPAND_HORIZ, FILL_BOTH, FILL_HORIZ and context from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() # # Path: epymc/gui.py # EXPAND_BOTH = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND # # EXPAND_HORIZ = evas.EVAS_HINT_EXPAND, 0.0 # # FILL_BOTH = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL # # FILL_HORIZ = evas.EVAS_HINT_FILL, 0.5 , which may contain function names, class names, or code. Output only the next line.
class FileManagerModule(EmcModule):
Given snippet: <|code_start|> self.build_ui() gui.signal_emit('fileman,show') gui.signal_emit('topbar,show') gui.text_set('topbar.title', _('File Manager')) gui.swallow_set('topbar.icon', gui.EmcImage(self.icon)) input_events.listener_add('fileman', self.input_event_cb) for w in self.widgets: w.focus_allow = True self.list1.focus = True self.list1.first_item.selected = True def hide(self): for w in self.widgets: w.focus = False w.focus_allow = False input_events.listener_del('fileman') gui.signal_emit('fileman,hide') gui.signal_emit('topbar,hide') mainmenu.show() def cb_mainmenu(self, url=None): mainmenu.hide() self.show() def build_ui(self): if self.ui_built: return def btn_add(label, cb): b = gui.EmcButton(gui.layout, label, cb=cb, <|code_end|> , continue by predicting the next line. Consider current file imports: import os import threading import queue import epymc.mainmenu as mainmenu import epymc.input_events as input_events import epymc.storage as storage import epymc.utils as utils import epymc.gui as gui import epymc.ini as ini from efl import ecore from efl.elementary.list import List from epymc.modules import EmcModule from epymc.gui import EXPAND_BOTH, EXPAND_HORIZ, FILL_BOTH, FILL_HORIZ and context: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() # # Path: epymc/gui.py # EXPAND_BOTH = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND # # EXPAND_HORIZ = evas.EVAS_HINT_EXPAND, 0.0 # # FILL_BOTH = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL # # FILL_HORIZ = evas.EVAS_HINT_FILL, 0.5 which might include code, classes, or functions. Output only the next line.
name=label, size_hint_fill=FILL_HORIZ)
Next line prediction: <|code_start|># This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function def DBG(msg): # print('WEBSERVER: %s' % msg) pass # msgs from thread to core, items are the input_event (ex. 'UP') input_queue = queue.Queue() <|code_end|> . Use current file imports: (import os import threading import queue import epymc.input_events as input_events import epymc.ini as ini from http.server import BaseHTTPRequestHandler, HTTPServer from efl import ecore from epymc.modules import EmcModule) and context including class names, function names, or small code snippets from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() . Output only the next line.
class WebserverModule(EmcModule):
Continue the code snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division api_base = 'https://api.vimeo.com' app_token = '55e9f802ceb814b649ef3c9504d4d38f' # Official token for EpyMC headers = {'Authorization': 'Bearer ' + app_token, 'User-Agent': 'EpyMC', 'Accept': 'application/vnd.vimeo.*+json;version=3.2'} icon_channels = local_resource(__file__, 'icon_channels.png') icon_groups = local_resource(__file__, 'icon_groups.png') icon_categories = local_resource(__file__, 'icon_categories.png') icon_users = local_resource(__file__, 'icon_users.png') icon_videos = 'icon/play' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_VIDEO_LIST = 1 ST_CHANN_LIST = 2 ST_GROUP_LIST = 3 ST_USERS_LIST = 4 ST_CATEGORIES = 5 ST_PLAY = 10 <|code_end|> . Use current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Continue the code snippet: <|code_start|>from __future__ import absolute_import, print_function, unicode_literals, division api_base = 'https://api.vimeo.com' app_token = '55e9f802ceb814b649ef3c9504d4d38f' # Official token for EpyMC headers = {'Authorization': 'Bearer ' + app_token, 'User-Agent': 'EpyMC', 'Accept': 'application/vnd.vimeo.*+json;version=3.2'} icon_channels = local_resource(__file__, 'icon_channels.png') icon_groups = local_resource(__file__, 'icon_groups.png') icon_categories = local_resource(__file__, 'icon_categories.png') icon_users = local_resource(__file__, 'icon_users.png') icon_videos = 'icon/play' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_VIDEO_LIST = 1 ST_CHANN_LIST = 2 ST_GROUP_LIST = 3 ST_USERS_LIST = 4 ST_CATEGORIES = 5 ST_PLAY = 10 STATE, URL = state_get() def vimeo_api_url(url): try: <|code_end|> . Use current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
return fetch_url(url, headers=headers, parser='json')
Here is a snippet: <|code_start|> poster = [c['link'] for c in cat['pictures']['sizes'] if c['width'] == 640][0] if '?' in poster: poster = poster.split('?')[0] except: poster = None videos = cat['metadata']['connections']['videos']['total'] channels = cat['metadata']['connections']['channels']['total'] groups = cat['metadata']['connections']['groups']['total'] info = '<title>%s</><br>' \ '<small><success>%d %s</> <name>/</> ' \ '<info>%d %s</> <name>/</> <warning>%d %s</></small>' % (name, videos, ngettext('video', 'videos', videos), channels, ngettext('channel', 'channels', channels), groups, ngettext('group', 'groups', groups)) item_add(NEXT_STATE, name, url, icon=icon_categories, info=info, poster=poster) for sub in cat['subcategories']: subname = name + ' - ' + sub['name'] url = api_base + sub['uri'] + URL + '?per_page=%d' % ITEMS_PER_PAGE item_add(NEXT_STATE, subname, url, icon=icon_categories, info=info, poster=poster) ################################################################################ # play a video using youtube-dl to get the real url \o/ ################################################################################ elif STATE == ST_PLAY: <|code_end|> . Write the next line using the current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may include functions, classes, or code. Output only the next line.
play_url(call_ydl(URL))
Here is a snippet: <|code_start|> api_base = 'https://api.vimeo.com' app_token = '55e9f802ceb814b649ef3c9504d4d38f' # Official token for EpyMC headers = {'Authorization': 'Bearer ' + app_token, 'User-Agent': 'EpyMC', 'Accept': 'application/vnd.vimeo.*+json;version=3.2'} icon_channels = local_resource(__file__, 'icon_channels.png') icon_groups = local_resource(__file__, 'icon_groups.png') icon_categories = local_resource(__file__, 'icon_categories.png') icon_users = local_resource(__file__, 'icon_users.png') icon_videos = 'icon/play' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_VIDEO_LIST = 1 ST_CHANN_LIST = 2 ST_GROUP_LIST = 3 ST_USERS_LIST = 4 ST_CATEGORIES = 5 ST_PLAY = 10 STATE, URL = state_get() def vimeo_api_url(url): try: return fetch_url(url, headers=headers, parser='json') except HTTPError as e: <|code_end|> . Write the next line using the current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may include functions, classes, or code. Output only the next line.
report_error('%d: %s' % (e.code, e.reason))
Next line prediction: <|code_start|> report_error('%s' % e.reason) sys.exit(1) def vimeo_api_call(endpoint, **kargs): url = api_base + endpoint + '?' + url_encode(kargs) return vimeo_api_url(url) def video_item_add(video): try: poster = [p['link'] for p in video['pictures']['sizes'] if p['width'] == 640][0] if '?' in poster: poster = poster.split('?')[0] except: poster = None views = video['stats']['plays'] or 0 likes = video['metadata']['connections']['likes']['total'] or 0 comments = video['metadata']['connections']['comments']['total'] or 0 info = '<title>%s</> <small>%s</small><br>' \ '<small><name>%s</> %s <name>/ %s %s</><br>' \ '<success>%s %s</> <name>/</> ' \ '<warning>%s %s</> <name>/</> ' \ '<info>%s %s</></small><br>%s' % ( video['name'], seconds_to_duration(video['duration']), _('user'), video['user']['name'], _('uploaded'), relative_date(video['created_time']), views, ngettext('view', 'views', views), likes, ngettext('like', 'likes', likes), comments, ngettext('comment', 'comments', comments), video['description'] or '') <|code_end|> . Use current file imports: (import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_PLAY, video['name'], video['link'], icon=icon_videos,
Next line prediction: <|code_start|> poster = [c['link'] for c in cat['pictures']['sizes'] if c['width'] == 640][0] if '?' in poster: poster = poster.split('?')[0] except: poster = None videos = cat['metadata']['connections']['videos']['total'] channels = cat['metadata']['connections']['channels']['total'] groups = cat['metadata']['connections']['groups']['total'] info = '<title>%s</><br>' \ '<small><success>%d %s</> <name>/</> ' \ '<info>%d %s</> <name>/</> <warning>%d %s</></small>' % (name, videos, ngettext('video', 'videos', videos), channels, ngettext('channel', 'channels', channels), groups, ngettext('group', 'groups', groups)) item_add(NEXT_STATE, name, url, icon=icon_categories, info=info, poster=poster) for sub in cat['subcategories']: subname = name + ' - ' + sub['name'] url = api_base + sub['uri'] + URL + '?per_page=%d' % ITEMS_PER_PAGE item_add(NEXT_STATE, subname, url, icon=icon_categories, info=info, poster=poster) ################################################################################ # play a video using youtube-dl to get the real url \o/ ################################################################################ elif STATE == ST_PLAY: <|code_end|> . Use current file imports: (import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(call_ydl(URL))
Given the code snippet: <|code_start|>#!/usr/bin/env python # This Python file uses the following encoding: utf-8 # # Copyright (C) 2010-2018 Davide Andreoli <dave@gurumeditation.it> # # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division api_base = 'https://api.vimeo.com' app_token = '55e9f802ceb814b649ef3c9504d4d38f' # Official token for EpyMC headers = {'Authorization': 'Bearer ' + app_token, 'User-Agent': 'EpyMC', 'Accept': 'application/vnd.vimeo.*+json;version=3.2'} <|code_end|> , generate the next line using the imports in this file: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
icon_channels = local_resource(__file__, 'icon_channels.png')
Based on the snippet: <|code_start|> try: return fetch_url(url, headers=headers, parser='json') except HTTPError as e: report_error('%d: %s' % (e.code, e.reason)) except URLError as e: report_error('%s' % e.reason) sys.exit(1) def vimeo_api_call(endpoint, **kargs): url = api_base + endpoint + '?' + url_encode(kargs) return vimeo_api_url(url) def video_item_add(video): try: poster = [p['link'] for p in video['pictures']['sizes'] if p['width'] == 640][0] if '?' in poster: poster = poster.split('?')[0] except: poster = None views = video['stats']['plays'] or 0 likes = video['metadata']['connections']['likes']['total'] or 0 comments = video['metadata']['connections']['comments']['total'] or 0 info = '<title>%s</> <small>%s</small><br>' \ '<small><name>%s</> %s <name>/ %s %s</><br>' \ '<success>%s %s</> <name>/</> ' \ '<warning>%s %s</> <name>/</> ' \ '<info>%s %s</></small><br>%s' % ( video['name'], seconds_to_duration(video['duration']), _('user'), video['user']['name'], <|code_end|> , predict the immediate next line with the help of imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
_('uploaded'), relative_date(video['created_time']),
Given the code snippet: <|code_start|> def vimeo_api_url(url): try: return fetch_url(url, headers=headers, parser='json') except HTTPError as e: report_error('%d: %s' % (e.code, e.reason)) except URLError as e: report_error('%s' % e.reason) sys.exit(1) def vimeo_api_call(endpoint, **kargs): url = api_base + endpoint + '?' + url_encode(kargs) return vimeo_api_url(url) def video_item_add(video): try: poster = [p['link'] for p in video['pictures']['sizes'] if p['width'] == 640][0] if '?' in poster: poster = poster.split('?')[0] except: poster = None views = video['stats']['plays'] or 0 likes = video['metadata']['connections']['likes']['total'] or 0 comments = video['metadata']['connections']['comments']['total'] or 0 info = '<title>%s</> <small>%s</small><br>' \ '<small><name>%s</> %s <name>/ %s %s</><br>' \ '<success>%s %s</> <name>/</> ' \ '<warning>%s %s</> <name>/</> ' \ '<info>%s %s</></small><br>%s' % ( <|code_end|> , generate the next line using the imports in this file: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
video['name'], seconds_to_duration(video['duration']),
Based on the snippet: <|code_start|>icon_channels = local_resource(__file__, 'icon_channels.png') icon_groups = local_resource(__file__, 'icon_groups.png') icon_categories = local_resource(__file__, 'icon_categories.png') icon_users = local_resource(__file__, 'icon_users.png') icon_videos = 'icon/play' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_VIDEO_LIST = 1 ST_CHANN_LIST = 2 ST_GROUP_LIST = 3 ST_USERS_LIST = 4 ST_CATEGORIES = 5 ST_PLAY = 10 STATE, URL = state_get() def vimeo_api_url(url): try: return fetch_url(url, headers=headers, parser='json') except HTTPError as e: report_error('%d: %s' % (e.code, e.reason)) except URLError as e: report_error('%s' % e.reason) sys.exit(1) def vimeo_api_call(endpoint, **kargs): <|code_end|> , predict the immediate next line with the help of imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
url = api_base + endpoint + '?' + url_encode(kargs)
Given snippet: <|code_start|> api_base = 'https://api.vimeo.com' app_token = '55e9f802ceb814b649ef3c9504d4d38f' # Official token for EpyMC headers = {'Authorization': 'Bearer ' + app_token, 'User-Agent': 'EpyMC', 'Accept': 'application/vnd.vimeo.*+json;version=3.2'} icon_channels = local_resource(__file__, 'icon_channels.png') icon_groups = local_resource(__file__, 'icon_groups.png') icon_categories = local_resource(__file__, 'icon_categories.png') icon_users = local_resource(__file__, 'icon_users.png') icon_videos = 'icon/play' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_VIDEO_LIST = 1 ST_CHANN_LIST = 2 ST_GROUP_LIST = 3 ST_USERS_LIST = 4 ST_CATEGORIES = 5 ST_PLAY = 10 STATE, URL = state_get() def vimeo_api_url(url): try: return fetch_url(url, headers=headers, parser='json') except HTTPError as e: report_error('%d: %s' % (e.code, e.reason)) <|code_end|> , continue by predicting the next line. Consider current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): which might include code, classes, or functions. Output only the next line.
except URLError as e:
Given the following code snippet before the placeholder: <|code_start|> api_base = 'https://api.vimeo.com' app_token = '55e9f802ceb814b649ef3c9504d4d38f' # Official token for EpyMC headers = {'Authorization': 'Bearer ' + app_token, 'User-Agent': 'EpyMC', 'Accept': 'application/vnd.vimeo.*+json;version=3.2'} icon_channels = local_resource(__file__, 'icon_channels.png') icon_groups = local_resource(__file__, 'icon_groups.png') icon_categories = local_resource(__file__, 'icon_categories.png') icon_users = local_resource(__file__, 'icon_users.png') icon_videos = 'icon/play' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_VIDEO_LIST = 1 ST_CHANN_LIST = 2 ST_GROUP_LIST = 3 ST_USERS_LIST = 4 ST_CATEGORIES = 5 ST_PLAY = 10 STATE, URL = state_get() def vimeo_api_url(url): try: return fetch_url(url, headers=headers, parser='json') <|code_end|> , predict the next line using imports from the current file: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
except HTTPError as e:
Continue the code snippet: <|code_start|> poster = None info = '<title>%s</><br>' \ '<small><name>%s</> %s<br>' \ '<name>%s</> %s</small><br>%s' % ( user['name'], _('joined'), relative_date(user['created_time']), _('location'), user['location'] or _('Unknown'), user['bio'] or '') item_add(ST_VIDEO_LIST, user['name'], url, icon=icon_users, poster=poster, info=info) ################################################################################ # home page ################################################################################ if STATE == ST_HOME: # searches item_add(ST_VIDEO_LIST, _('Search videos'), 'search1', action=ACT_SEARCH) item_add(ST_CHANN_LIST, _('Search channels'), 'search2', action=ACT_SEARCH) item_add(ST_GROUP_LIST, _('Search groups'), 'search3', action=ACT_SEARCH) item_add(ST_USERS_LIST, _('Search people'), 'search4', action=ACT_SEARCH) # more relevant videos (THIS DO NOT WORK, need to find another api) # url = api_base + '/videos?sort=relevant&per_page=%d' % ITEMS_PER_PAGE # item_add(ST_VIDEO_LIST, _('More relevant videos'), url, # icon=icon_videos, action=ACT_FOLDER) # more followed channels url = api_base + '/channels?sort=followers&per_page=%d' % ITEMS_PER_PAGE item_add(ST_CHANN_LIST, _('More followed channels'), url, <|code_end|> . Use current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
icon=icon_channels, action=ACT_FOLDER)
Continue the code snippet: <|code_start|> url = api_base + '/groups?sort=followers&per_page=%d' % ITEMS_PER_PAGE item_add(ST_GROUP_LIST, _('More followed groups'), url, icon=icon_groups, action=ACT_FOLDER) # more relevant users (DO NOT WORK) # url = api_base + '/users?sort=relevant&per_page=%d' % ITEMS_PER_PAGE # item_add(ST_USERS_LIST, 'More relevant users', url, # icon=icon_users, action=ACT_FOLDER) # browse by cats item_add(ST_CATEGORIES, _('Browse videos'), '/videos', action=ACT_FOLDER) item_add(ST_CATEGORIES, _('Browse channels'), '/channels', action=ACT_FOLDER) item_add(ST_CATEGORIES, _('Browse groups'), '/groups', action=ACT_FOLDER) item_add(ST_CATEGORIES, _('Browse users'), '/users', action=ACT_FOLDER) ################################################################################ # videos list ################################################################################ elif STATE == ST_VIDEO_LIST: if URL.startswith(api_base): results = vimeo_api_url(URL) else: results = vimeo_api_call('/videos', query=URL, per_page=ITEMS_PER_PAGE) for video in results['data']: video_item_add(video) if results['paging']['next']: url = api_base + results['paging']['next'] text = _('Load more results (%d in total)') % results['total'] <|code_end|> . Use current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_VIDEO_LIST, text, url, action=ACT_MORE)
Here is a snippet: <|code_start|> videos, ngettext('video', 'videos', videos), followers, ngettext('follower', 'followers', followers), group['description'] or '') item_add(ST_VIDEO_LIST, group['name'], url, icon=icon_groups, poster=poster, info=info) def user_item_add(user): url = api_base + user['metadata']['connections']['videos']['uri'] try: poster = [p['link'] for p in user['pictures']['sizes'] if p['width'] == 300][0] if '?' in poster: poster = poster.split('?')[0] except: poster = None info = '<title>%s</><br>' \ '<small><name>%s</> %s<br>' \ '<name>%s</> %s</small><br>%s' % ( user['name'], _('joined'), relative_date(user['created_time']), _('location'), user['location'] or _('Unknown'), user['bio'] or '') item_add(ST_VIDEO_LIST, user['name'], url, icon=icon_users, poster=poster, info=info) ################################################################################ # home page ################################################################################ if STATE == ST_HOME: # searches <|code_end|> . Write the next line using the current file imports: import sys from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \ relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may include functions, classes, or code. Output only the next line.
item_add(ST_VIDEO_LIST, _('Search videos'), 'search1', action=ACT_SEARCH)
Here is a snippet: <|code_start|># (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 __future__ import absolute_import, print_function sheets = [ '97VkS.png', 'EBU_3325_1080_7_video.png', 'Overscan-2.jpg', 'AVStest-black.png', 'AVStest-black_white.png', 'greyscale-ramp.png', 'bars601.jpg', 'Slide01.jpg', '6291.png', ] # http://gonedigital.net/2010/04/19/ <|code_end|> . Write the next line using the current file imports: import os import epymc.config_gui as config_gui import epymc.input_events as input_events import epymc.gui as gui from efl.elementary.image import Image from epymc.modules import EmcModule from epymc.gui import EXPAND_BOTH, FILL_BOTH and context from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() # # Path: epymc/gui.py # EXPAND_BOTH = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND # # FILL_BOTH = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL , which may include functions, classes, or code. Output only the next line.
class CalibratorModule(EmcModule):
Continue the code snippet: <|code_start|> 'Overscan-2.jpg', 'AVStest-black.png', 'AVStest-black_white.png', 'greyscale-ramp.png', 'bars601.jpg', 'Slide01.jpg', '6291.png', ] # http://gonedigital.net/2010/04/19/ class CalibratorModule(EmcModule): name = 'calibrator' label = _('Screen calibrator') icon = 'icon/calib' info = _('Use this module to calibrate your screen parameters.') path = os.path.dirname(__file__) def __init__(self): config_gui.root_item_add('calibrator', 100, _('Screen calibrator'), icon='icon/calib', callback=self.startup) self.i = None self.current = -1 def __shutdown__(self): config_gui.root_item_del('calibrator') def startup(self): self.i = Image(gui.win, aspect_fixed=False, <|code_end|> . Use current file imports: import os import epymc.config_gui as config_gui import epymc.input_events as input_events import epymc.gui as gui from efl.elementary.image import Image from epymc.modules import EmcModule from epymc.gui import EXPAND_BOTH, FILL_BOTH and context (classes, functions, or code) from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() # # Path: epymc/gui.py # EXPAND_BOTH = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND # # FILL_BOTH = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL . Output only the next line.
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
Continue the code snippet: <|code_start|> 'Overscan-2.jpg', 'AVStest-black.png', 'AVStest-black_white.png', 'greyscale-ramp.png', 'bars601.jpg', 'Slide01.jpg', '6291.png', ] # http://gonedigital.net/2010/04/19/ class CalibratorModule(EmcModule): name = 'calibrator' label = _('Screen calibrator') icon = 'icon/calib' info = _('Use this module to calibrate your screen parameters.') path = os.path.dirname(__file__) def __init__(self): config_gui.root_item_add('calibrator', 100, _('Screen calibrator'), icon='icon/calib', callback=self.startup) self.i = None self.current = -1 def __shutdown__(self): config_gui.root_item_del('calibrator') def startup(self): self.i = Image(gui.win, aspect_fixed=False, <|code_end|> . Use current file imports: import os import epymc.config_gui as config_gui import epymc.input_events as input_events import epymc.gui as gui from efl.elementary.image import Image from epymc.modules import EmcModule from epymc.gui import EXPAND_BOTH, FILL_BOTH and context (classes, functions, or code) from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() # # Path: epymc/gui.py # EXPAND_BOTH = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND # # FILL_BOTH = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL . Output only the next line.
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
Here is a snippet: <|code_start|># This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division url_base = 'http://fantasti.cc' ST_HOME = 0 ST_VIDEO_LIST = 1 ST_COLLECTION_LIST = 2 ST_COLLECTION_VIDEO_LIST = 3 ST_SEARCH = 4 ST_SEARCH_RES = 5 ST_CATEGORIES_LIST = 6 ST_PLAY = 69 <|code_end|> . Write the next line using the current file imports: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may include functions, classes, or code. Output only the next line.
STATE, URL = state_get()
Using the snippet: <|code_start|> # this is the first page, show fixed categories if STATE == ST_HOME: # item_add(ST_PLAY,'A Random Video', 'http://fantasti.cc/random.php?v=1') item_add(ST_SEARCH, 'Search videos', 'search', action=ACT_SEARCH) item_add(ST_VIDEO_LIST, 'Upcoming video', url_base + '/videos/upcoming', action=ACT_FOLDER) item_add(ST_CATEGORIES_LIST, 'Categories', url_base + '/category', action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Popular today', url_base + '/videos/popular/today', action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Popular this week', url_base + '/videos/popular/7days', action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Popular this month', url_base + '/videos/popular/31days', action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Popular all time', url_base + '/videos/popular/all_time', action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Popular made popular', url_base + '/videos/popular/made_popular', action=ACT_FOLDER) item_add(ST_COLLECTION_LIST, 'Collections - Popular', url_base + '/videos/collections/popular/31days', action=ACT_FOLDER) item_add(ST_COLLECTION_LIST, 'Collections - Top Rated', url_base + '/videos/collections/top_rated/31days', action=ACT_FOLDER) item_add(ST_COLLECTION_LIST, 'Collections - Most Viewed', url_base + '/videos/collections/most_viewed/31days', action=ACT_FOLDER) item_add(ST_COLLECTION_LIST, 'Collections - Most Discussed', url_base + '/videos/collections/most_discussed/31days', action=ACT_FOLDER) item_add(ST_COLLECTION_LIST, 'Collections - Top Favorites', url_base + '/videos/collections/top_favorites/31days', action=ACT_FOLDER) # handle a page with a list of videos (popular videos) elif STATE == ST_VIDEO_LIST: <|code_end|> , determine the next line of code. You have imports: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
soup = fetch_url(URL, parser='bs4')
Given snippet: <|code_start|> except: pass # handle the list of categories elif STATE == ST_CATEGORIES_LIST: soup = fetch_url(URL, parser='bs4') for div in soup.findAll('div', class_='content-block-category'): name = div.find('span', class_='category-name').string url = url_base + div.find('a')['href'] url = url.replace('category', 'search') + 'tube/' try: thumb = div.find('div', class_='thumb')['data-src'] except KeyError: try: thumb = div.find('div', class_='thumb')['style'] thumb = thumb.split("('", 1)[1].split("')")[0] except: thumb = None item_add(ST_SEARCH_RES, name, url, icon=thumb, poster=thumb) # read a page with a single video and play the video elif STATE == ST_PLAY: soup = fetch_url(URL, parser='bs4') link = soup.find('div', class_='video-wrap')['data-origin-source'] url = call_ydl(link) if not url: url = call_ydl(URL) if url: <|code_end|> , continue by predicting the next line. Consider current file imports: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): which might include code, classes, or functions. Output only the next line.
play_url(url)
Predict the next line after this snippet: <|code_start|># (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 __future__ import absolute_import, print_function, unicode_literals, division url_base = 'http://fantasti.cc' ST_HOME = 0 ST_VIDEO_LIST = 1 ST_COLLECTION_LIST = 2 ST_COLLECTION_VIDEO_LIST = 3 ST_SEARCH = 4 ST_SEARCH_RES = 5 ST_CATEGORIES_LIST = 6 ST_PLAY = 69 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: # item_add(ST_PLAY,'A Random Video', 'http://fantasti.cc/random.php?v=1') <|code_end|> using the current file's imports: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_SEARCH, 'Search videos', 'search', action=ACT_SEARCH)
Given the code snippet: <|code_start|> # more items... try: url = 'http://fantasti.cc/' + soup.find('a', text='next >>')['href'] item_add(ST_SEARCH_RES, 'More items...', url, action=ACT_MORE) except: pass # handle the list of categories elif STATE == ST_CATEGORIES_LIST: soup = fetch_url(URL, parser='bs4') for div in soup.findAll('div', class_='content-block-category'): name = div.find('span', class_='category-name').string url = url_base + div.find('a')['href'] url = url.replace('category', 'search') + 'tube/' try: thumb = div.find('div', class_='thumb')['data-src'] except KeyError: try: thumb = div.find('div', class_='thumb')['style'] thumb = thumb.split("('", 1)[1].split("')")[0] except: thumb = None item_add(ST_SEARCH_RES, name, url, icon=thumb, poster=thumb) # read a page with a single video and play the video elif STATE == ST_PLAY: soup = fetch_url(URL, parser='bs4') link = soup.find('div', class_='video-wrap')['data-origin-source'] <|code_end|> , generate the next line using the imports in this file: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
url = call_ydl(link)
Predict the next line for this snippet: <|code_start|> # handle the list of categories elif STATE == ST_CATEGORIES_LIST: soup = fetch_url(URL, parser='bs4') for div in soup.findAll('div', class_='content-block-category'): name = div.find('span', class_='category-name').string url = url_base + div.find('a')['href'] url = url.replace('category', 'search') + 'tube/' try: thumb = div.find('div', class_='thumb')['data-src'] except KeyError: try: thumb = div.find('div', class_='thumb')['style'] thumb = thumb.split("('", 1)[1].split("')")[0] except: thumb = None item_add(ST_SEARCH_RES, name, url, icon=thumb, poster=thumb) # read a page with a single video and play the video elif STATE == ST_PLAY: soup = fetch_url(URL, parser='bs4') link = soup.find('div', class_='video-wrap')['data-origin-source'] url = call_ydl(link) if not url: url = call_ydl(URL) if url: play_url(url) else: <|code_end|> with the help of current file imports: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
report_error('Video not found')
Given the following code snippet before the placeholder: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division url_base = 'http://fantasti.cc' ST_HOME = 0 ST_VIDEO_LIST = 1 ST_COLLECTION_LIST = 2 ST_COLLECTION_VIDEO_LIST = 3 ST_SEARCH = 4 ST_SEARCH_RES = 5 ST_CATEGORIES_LIST = 6 ST_PLAY = 69 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: # item_add(ST_PLAY,'A Random Video', 'http://fantasti.cc/random.php?v=1') item_add(ST_SEARCH, 'Search videos', 'search', action=ACT_SEARCH) <|code_end|> , predict the next line using imports from the current file: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_VIDEO_LIST, 'Upcoming video', url_base + '/videos/upcoming', action=ACT_FOLDER)
Given the following code snippet before the placeholder: <|code_start|># handle a page with a list of videos (popular videos) elif STATE == ST_VIDEO_LIST: soup = fetch_url(URL, parser='bs4') loop = soup.findAll('div', class_='loop') for div in loop: title = div.find('a', class_='title').string thumb = div.find('img', class_='img_100')['src'] url = 'http://fantasti.cc/' + div.find('a')['href'] try: # what a mess for the info ... infos = div.find('span', style='font-size:11px;').get_text('|', strip=True).split('|') info1 = infos[0].split('\n')[0].strip() duration = info1.split('.')[0] uploaded = info1.split(':')[-1] from_ = infos[1] tags = ', '.join(infos[2:]) info = '<title>%s</title><br>' \ '<name>Duration:</name> %s<br>' \ '<name>source</name> %s <name>/ uploaded %s</name><br>' \ '<name>Tags:</name> %s' % \ (title, duration, from_, uploaded, tags) except: info = None item_add(ST_PLAY, title, url, poster=thumb, info=info) # more items... try: url = 'http://fantasti.cc/' + soup.find('a', text='next >>')['href'] <|code_end|> , predict the next line using imports from the current file: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_VIDEO_LIST, 'More items...', url, action=ACT_MORE)
Predict the next line for this snippet: <|code_start|># (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 __future__ import absolute_import, print_function, unicode_literals, division url_base = 'http://fantasti.cc' ST_HOME = 0 ST_VIDEO_LIST = 1 ST_COLLECTION_LIST = 2 ST_COLLECTION_VIDEO_LIST = 3 ST_SEARCH = 4 ST_SEARCH_RES = 5 ST_CATEGORIES_LIST = 6 ST_PLAY = 69 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: # item_add(ST_PLAY,'A Random Video', 'http://fantasti.cc/random.php?v=1') <|code_end|> with the help of current file imports: import re import json from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
item_add(ST_SEARCH, 'Search videos', 'search', action=ACT_SEARCH)
Given the following code snippet before the placeholder: <|code_start|> (name, cb, data) = lis DBG(' * ' + name) def listener_del(name): global _listeners DBG('Listener Del: ' + name) for lis in _listeners: (n, cb, data) = lis if n == name: _listeners.remove(lis) return def listener_promote(name): global _listeners DBG('Listener Promote: ' + name) for lis in _listeners: (n, cb, data) = lis if n == name: _listeners.remove(lis) _listeners.append(lis) return def event_emit(event): DBG('Emit Event: ' + event + ' listeners: ' + str(len(_listeners))) <|code_end|> , predict the next line using imports from the current file: from epymc import events and context including class names, function names, and sometimes code from other files: # Path: epymc/events.py # def DBG(msg): # def listener_add(name, func, *a, **ka): # def listener_add_single_shot(event, func, *a, **ka): # def listener_del(name): # def event_emit(event): . Output only the next line.
events.event_emit('KEEP_ALIVE')
Using the snippet: <|code_start|>#!/usr/bin/env python # This Python file uses the following encoding: utf-8 # # Copyright (C) 2010-2018 Davide Andreoli <dave@gurumeditation.it> # # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, division, unicode_literals def DBG(msg): print('WATCHDOG: %s' % msg) <|code_end|> , determine the next line of code. You have imports: import os import efl.ecore as ecore from epymc.modules import EmcModule and context (class names, function names, or code) available: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() . Output only the next line.
class Watchdog(EmcModule):
Using the snippet: <|code_start|># This Python file uses the following encoding: utf-8 # # Copyright (C) 2010-2018 Davide Andreoli <dave@gurumeditation.it> # # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_EPISODES_LIST = 1 ST_ACTS_LIST = 2 ST_NONE = 4 base = 'http://southpark.cc.com/' json_base = 'http://southpark.cc.com/feeds/carousel/video/6154fc40-b7a3-4387-94cc-fc42fc47376e/30/1/json/!airdate/' <|code_end|> , determine the next line of code. You have imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Using the snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_EPISODES_LIST = 1 ST_ACTS_LIST = 2 ST_NONE = 4 base = 'http://southpark.cc.com/' json_base = 'http://southpark.cc.com/feeds/carousel/video/6154fc40-b7a3-4387-94cc-fc42fc47376e/30/1/json/!airdate/' STATE, URL = state_get() # this is the first page, show fixed seasons list if STATE == ST_HOME: for i in range(1, 20): item_add(ST_EPISODES_LIST, label=_('Season {0}').format(i), url='{}season-{}'.format(json_base, i), poster=local_resource(__file__, 'season{}.jpg'.format(i))) # show the episodes of a single season elif STATE == ST_EPISODES_LIST: <|code_end|> , determine the next line of code. You have imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
season_data = fetch_url(URL, parser='json')
Continue the code snippet: <|code_start|># # 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_EPISODES_LIST = 1 ST_ACTS_LIST = 2 ST_NONE = 4 base = 'http://southpark.cc.com/' json_base = 'http://southpark.cc.com/feeds/carousel/video/6154fc40-b7a3-4387-94cc-fc42fc47376e/30/1/json/!airdate/' STATE, URL = state_get() # this is the first page, show fixed seasons list if STATE == ST_HOME: for i in range(1, 20): <|code_end|> . Use current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_EPISODES_LIST, label=_('Season {0}').format(i),
Based on the snippet: <|code_start|> STATE, URL = state_get() # this is the first page, show fixed seasons list if STATE == ST_HOME: for i in range(1, 20): item_add(ST_EPISODES_LIST, label=_('Season {0}').format(i), url='{}season-{}'.format(json_base, i), poster=local_resource(__file__, 'season{}.jpg'.format(i))) # show the episodes of a single season elif STATE == ST_EPISODES_LIST: season_data = fetch_url(URL, parser='json') for num, episode_data in enumerate(season_data['results'], start=1): title = '{}. {}'.format(num, episode_data['title']) poster = episode_data['images'] air_date = int(episode_data['originalAirDate']) info = '<title>{}: {}</title><br>' \ '<name>{}:</name> {}<br>{}'.format( _('Episode {0}').format(num), episode_data['title'], _('First aired'), format_date(air_date), episode_data['description']) item_add(ST_ACTS_LIST, title, url=episode_data['_url']['default'], info=info, poster=poster) # show the list of acts for a single episode (can be played directly) elif STATE == ST_ACTS_LIST: <|code_end|> , predict the immediate next line with the help of imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
urls = call_ydl(URL).splitlines()
Continue the code snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_EPISODES_LIST = 1 ST_ACTS_LIST = 2 ST_NONE = 4 base = 'http://southpark.cc.com/' json_base = 'http://southpark.cc.com/feeds/carousel/video/6154fc40-b7a3-4387-94cc-fc42fc47376e/30/1/json/!airdate/' STATE, URL = state_get() # this is the first page, show fixed seasons list if STATE == ST_HOME: for i in range(1, 20): item_add(ST_EPISODES_LIST, label=_('Season {0}').format(i), url='{}season-{}'.format(json_base, i), <|code_end|> . Use current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
poster=local_resource(__file__, 'season{}.jpg'.format(i)))
Predict the next line for this snippet: <|code_start|> ST_HOME = 0 ST_EPISODES_LIST = 1 ST_ACTS_LIST = 2 ST_NONE = 4 base = 'http://southpark.cc.com/' json_base = 'http://southpark.cc.com/feeds/carousel/video/6154fc40-b7a3-4387-94cc-fc42fc47376e/30/1/json/!airdate/' STATE, URL = state_get() # this is the first page, show fixed seasons list if STATE == ST_HOME: for i in range(1, 20): item_add(ST_EPISODES_LIST, label=_('Season {0}').format(i), url='{}season-{}'.format(json_base, i), poster=local_resource(__file__, 'season{}.jpg'.format(i))) # show the episodes of a single season elif STATE == ST_EPISODES_LIST: season_data = fetch_url(URL, parser='json') for num, episode_data in enumerate(season_data['results'], start=1): title = '{}. {}'.format(num, episode_data['title']) poster = episode_data['images'] air_date = int(episode_data['originalAirDate']) info = '<title>{}: {}</title><br>' \ '<name>{}:</name> {}<br>{}'.format( _('Episode {0}').format(num), episode_data['title'], <|code_end|> with the help of current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
_('First aired'), format_date(air_date),
Here is a snippet: <|code_start|># this is the first page, show fixed seasons list if STATE == ST_HOME: for i in range(1, 20): item_add(ST_EPISODES_LIST, label=_('Season {0}').format(i), url='{}season-{}'.format(json_base, i), poster=local_resource(__file__, 'season{}.jpg'.format(i))) # show the episodes of a single season elif STATE == ST_EPISODES_LIST: season_data = fetch_url(URL, parser='json') for num, episode_data in enumerate(season_data['results'], start=1): title = '{}. {}'.format(num, episode_data['title']) poster = episode_data['images'] air_date = int(episode_data['originalAirDate']) info = '<title>{}: {}</title><br>' \ '<name>{}:</name> {}<br>{}'.format( _('Episode {0}').format(num), episode_data['title'], _('First aired'), format_date(air_date), episode_data['description']) item_add(ST_ACTS_LIST, title, url=episode_data['_url']['default'], info=info, poster=poster) # show the list of acts for a single episode (can be played directly) elif STATE == ST_ACTS_LIST: urls = call_ydl(URL).splitlines() for i, act_url in enumerate(urls, start=1): act_icon = local_resource(__file__, 'act{}.jpg'.format(i)) <|code_end|> . Write the next line using the current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, local_resource, format_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may include functions, classes, or code. Output only the next line.
item_add(ST_NONE, 'Act #{}'.format(i), act_url, icon=act_icon, action=ACT_PLAY)
Predict the next line after this snippet: <|code_start|># # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division ytb_base = 'https://www.youtube.com' ytb_icon = local_resource(__file__, 'youtube.png') ST_HOME = 0 ST_PLAY = 1 ST_SEARCH = 3 ST_CHN_CATEGORIES = 10 ST_CHN_CHANNELS = 11 ST_CHN_VIDEOS = 12 <|code_end|> using the current file's imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Using the snippet: <|code_start|> ytb_base = 'https://www.youtube.com' ytb_icon = local_resource(__file__, 'youtube.png') ST_HOME = 0 ST_PLAY = 1 ST_SEARCH = 3 ST_CHN_CATEGORIES = 10 ST_CHN_CHANNELS = 11 ST_CHN_VIDEOS = 12 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: item_add(ST_SEARCH, _('Search videos'), 'search', None, action=ACT_SEARCH) item_add(ST_CHN_CATEGORIES, _('Browse channels'), ytb_base + '/channels', None, action=ACT_FOLDER) ############################################################################### # youtube site scraper ######################################################## ############################################################################### # 0. search results if STATE == ST_SEARCH: if not URL.startswith(ytb_base): # first page, URL is the search query entered by the user URL = ytb_base + '/results?' + url_encode( {'search_query': URL, 'filters': 'video'}) <|code_end|> , determine the next line of code. You have imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
soup = fetch_url(URL, parser='bs4')
Continue the code snippet: <|code_start|> # 3. show a list of videos in a given channel elif STATE == ST_CHN_VIDEOS: soup = fetch_url(URL, parser='bs4') for div in soup.findAll('div', class_='yt-lockup-video'): id = div['data-context-item-id'] title = div.find('h3', class_='yt-lockup-title').find('a')['title'] url = ytb_base + '/watch?v=' + id poster = 'http://i.ytimg.com/vi/' + id + '/hqdefault.jpg' duration = div.find('span', class_='video-time').string descr = div.find('div', class_='yt-lockup-description') meta = div.find('ul', class_='yt-lockup-meta-info') li = meta.find('li') uploaded = li.string views = li.next_sibling.string info = '<title>%s</title> <small>%s</small><br>' \ '<small><name>%s %s</name><br>' \ '<success>%s</success></small>' \ '<br>%s' % ( title, duration, _('uploaded'), uploaded, views, descr) # or '') item_add(ST_PLAY, title, url, info=info, poster=poster) # 99. play a video using youtube-dl to get the real url \o/ elif STATE == ST_PLAY: # play the video using ytdl <|code_end|> . Use current file imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(call_ydl(URL))
Predict the next line for this snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division ytb_base = 'https://www.youtube.com' ytb_icon = local_resource(__file__, 'youtube.png') ST_HOME = 0 ST_PLAY = 1 ST_SEARCH = 3 ST_CHN_CATEGORIES = 10 ST_CHN_CHANNELS = 11 ST_CHN_VIDEOS = 12 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: <|code_end|> with the help of current file imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
item_add(ST_SEARCH, _('Search videos'), 'search', None, action=ACT_SEARCH)
Given the following code snippet before the placeholder: <|code_start|> # 3. show a list of videos in a given channel elif STATE == ST_CHN_VIDEOS: soup = fetch_url(URL, parser='bs4') for div in soup.findAll('div', class_='yt-lockup-video'): id = div['data-context-item-id'] title = div.find('h3', class_='yt-lockup-title').find('a')['title'] url = ytb_base + '/watch?v=' + id poster = 'http://i.ytimg.com/vi/' + id + '/hqdefault.jpg' duration = div.find('span', class_='video-time').string descr = div.find('div', class_='yt-lockup-description') meta = div.find('ul', class_='yt-lockup-meta-info') li = meta.find('li') uploaded = li.string views = li.next_sibling.string info = '<title>%s</title> <small>%s</small><br>' \ '<small><name>%s %s</name><br>' \ '<success>%s</success></small>' \ '<br>%s' % ( title, duration, _('uploaded'), uploaded, views, descr) # or '') item_add(ST_PLAY, title, url, info=info, poster=poster) # 99. play a video using youtube-dl to get the real url \o/ elif STATE == ST_PLAY: # play the video using ytdl <|code_end|> , predict the next line using imports from the current file: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(call_ydl(URL))
Predict the next line after this snippet: <|code_start|>from __future__ import absolute_import, print_function, unicode_literals, division ytb_base = 'https://www.youtube.com' ytb_icon = local_resource(__file__, 'youtube.png') ST_HOME = 0 ST_PLAY = 1 ST_SEARCH = 3 ST_CHN_CATEGORIES = 10 ST_CHN_CHANNELS = 11 ST_CHN_VIDEOS = 12 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: item_add(ST_SEARCH, _('Search videos'), 'search', None, action=ACT_SEARCH) item_add(ST_CHN_CATEGORIES, _('Browse channels'), ytb_base + '/channels', None, action=ACT_FOLDER) ############################################################################### # youtube site scraper ######################################################## ############################################################################### # 0. search results if STATE == ST_SEARCH: if not URL.startswith(ytb_base): # first page, URL is the search query entered by the user <|code_end|> using the current file's imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
URL = ytb_base + '/results?' + url_encode(
Using the snippet: <|code_start|># (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 __future__ import absolute_import, print_function, unicode_literals, division ytb_base = 'https://www.youtube.com' ytb_icon = local_resource(__file__, 'youtube.png') ST_HOME = 0 ST_PLAY = 1 ST_SEARCH = 3 ST_CHN_CATEGORIES = 10 ST_CHN_CHANNELS = 11 ST_CHN_VIDEOS = 12 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: item_add(ST_SEARCH, _('Search videos'), 'search', None, action=ACT_SEARCH) item_add(ST_CHN_CATEGORIES, _('Browse channels'), <|code_end|> , determine the next line of code. You have imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
ytb_base + '/channels', None, action=ACT_FOLDER)
Continue the code snippet: <|code_start|> soup = fetch_url(URL, parser='bs4') for div in soup.findAll('div', class_='yt-lockup-video'): id = div['data-context-item-id'] title = div.find('h3', class_='yt-lockup-title').find('a')['title'] url = ytb_base + '/watch?v=' + id poster = 'http://i.ytimg.com/vi/' + id + '/hqdefault.jpg' duration = div.find('span', class_='video-time').string user = div.find('div', class_='yt-lockup-byline').find('a').string descr = div.find('div', class_='yt-lockup-description') meta = div.find('ul', class_='yt-lockup-meta-info') if len(meta.contents) != 2: continue # skip Ad items uploaded = meta.contents[0].string views = meta.contents[1].string info = '<title>%s</> <small>%s</><br>' \ '<small><name>%s</> %s <name>/ %s %s</><br>' \ '<success>%s</></small>' \ '<br>%s' % ( title, duration, _('user'), user, _('uploaded'), uploaded, views, descr or '') item_add(ST_PLAY, title, url, info=info, poster=poster) # more items... try: url = ytb_base + soup.find('div', class_='search-pager').contents[-2]['href'] <|code_end|> . Use current file imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_SEARCH, _('More items...'), url, icon='icon/next', action=ACT_MORE)
Predict the next line after this snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division ytb_base = 'https://www.youtube.com' ytb_icon = local_resource(__file__, 'youtube.png') ST_HOME = 0 ST_PLAY = 1 ST_SEARCH = 3 ST_CHN_CATEGORIES = 10 ST_CHN_CHANNELS = 11 ST_CHN_VIDEOS = 12 STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: <|code_end|> using the current file's imports: import os from epymc.extapi.onlinevideo import api_version, state_get, fetch_url, \ play_url, item_add, call_ydl, local_resource, seconds_to_duration, \ relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_SEARCH, _('Search videos'), 'search', None, action=ACT_SEARCH)
Based on the snippet: <|code_start|> if mod.name == name: return mod return None def list_get(): return EmcModule.__subclasses__() def is_enabled(name): return name in _instances def init_by_name(name): for mod in EmcModule.__subclasses__(): if mod.name == name: if name not in _instances: try: _instances[name] = mod() except: traceback.print_exc() def init_all(): for mod in EmcModule.__subclasses__(): if mod.name not in _instances: _instances[mod.name] = mod() def init_all_by_config(): <|code_end|> , predict the immediate next line with the help of imports: import sys import os import traceback from epymc import ini from epymc import utils and context (classes, functions, sometimes code) from other files: # Path: epymc/ini.py # def read_from_files(files): # def write_to_file(file): # def setup_defaults(): # def add_section(section): # def has_section(section): # def has_option(section, option): # def has_options(options): # def get_options(section): # def get(section, option, default_value=None): # def get_string_list(section, option, separator=' '): # def get_int(section, option): # def get_float(section, option): # def get_bool(section, option): # def get_string(section, option): # def set(section, option, value): # def set_string_list(section, option, values, separator=' '): # def remove_option(section, option): # # Path: epymc/utils.py # XDG_CONFIG_HOME = '' # XDG_CACHE_HOME = '' # def LOG(*args): # def DBG(msg): # def iso639_1_to_3(iso1): # def iso639_1_to_5(iso1): # def is_py3(): # def is_py2(): # def get_resource_file(res_type, res_name, default=None): # def get_available_themes(): # def in_use_theme_file_set(theme_file): # def url2path(url): # def hum_size(bites): # def seconds_to_duration(seconds, hours=False): # def splitpath(path): # def ensure_file_not_exists(fullpath): # def md5(txt): # def user_name(): # def natural_sort(li): # def natural_cmp(a, b): # def grab_files(folders, show_hidden=False, recursive=True): # def download_url_async(url, dest='tmp', min_size=0, # complete_cb=None, progress_cb=None, # urlencode=True, *args, **kargs): # def _cb_download_complete(dest, status, dwl_data, *args, **kargs): # def _cb_download_progress(dest, dltotal, dlnow, uptotal, upnow, dwl_data, *args, **kargs): # def download_abort(dwl_handler): # def http_error_code_to_str(code): # def distance_between_point_and_segment(point, segment_p1, segment_p2, real=False): # def __new__(cls, *args, **kwargs): # def __init__(self, cmd, grab_output=False, done_cb=None, *args, **kargs): # def data_cb(self, exe, event): # def del_cb(self, exe, event): # def __init__(self, url, done_cb=None, prog_cb=None, headers=None, **kargs): # def _complete_cb(self, event): # def _data_cb(self, event): # class Singleton(object): # class EmcExec(object): # class EmcUrl(ecore_con.Url): . Output only the next line.
if not ini.has_option('general', 'modules'):
Here is a snippet: <|code_start|> def __shutdown__(self): pass def __restart__(self): self.__shutdown__() self.__init__() _instances = {} # key: module_name val: EmcModule instance def load_all(): def _scan_folder(path): LOG('Searching for modules in: %s' % path) if path not in sys.path: sys.path.insert(0, path) for root, dirs, files in os.walk(path): for name in dirs: f = os.path.join(root, name, '__init__.py') if os.path.isfile(f): try: LOG(' * loading: %s' % name) mod = __import__(name) except ImportError: LOG(' * FAILED: %s' % f) traceback.print_exc() LOG('') # load from the plugins/ dir relative to script position <|code_end|> . Write the next line using the current file imports: import sys import os import traceback from epymc import ini from epymc import utils and context from other files: # Path: epymc/ini.py # def read_from_files(files): # def write_to_file(file): # def setup_defaults(): # def add_section(section): # def has_section(section): # def has_option(section, option): # def has_options(options): # def get_options(section): # def get(section, option, default_value=None): # def get_string_list(section, option, separator=' '): # def get_int(section, option): # def get_float(section, option): # def get_bool(section, option): # def get_string(section, option): # def set(section, option, value): # def set_string_list(section, option, values, separator=' '): # def remove_option(section, option): # # Path: epymc/utils.py # XDG_CONFIG_HOME = '' # XDG_CACHE_HOME = '' # def LOG(*args): # def DBG(msg): # def iso639_1_to_3(iso1): # def iso639_1_to_5(iso1): # def is_py3(): # def is_py2(): # def get_resource_file(res_type, res_name, default=None): # def get_available_themes(): # def in_use_theme_file_set(theme_file): # def url2path(url): # def hum_size(bites): # def seconds_to_duration(seconds, hours=False): # def splitpath(path): # def ensure_file_not_exists(fullpath): # def md5(txt): # def user_name(): # def natural_sort(li): # def natural_cmp(a, b): # def grab_files(folders, show_hidden=False, recursive=True): # def download_url_async(url, dest='tmp', min_size=0, # complete_cb=None, progress_cb=None, # urlencode=True, *args, **kargs): # def _cb_download_complete(dest, status, dwl_data, *args, **kargs): # def _cb_download_progress(dest, dltotal, dlnow, uptotal, upnow, dwl_data, *args, **kargs): # def download_abort(dwl_handler): # def http_error_code_to_str(code): # def distance_between_point_and_segment(point, segment_p1, segment_p2, real=False): # def __new__(cls, *args, **kwargs): # def __init__(self, cmd, grab_output=False, done_cb=None, *args, **kargs): # def data_cb(self, exe, event): # def del_cb(self, exe, event): # def __init__(self, url, done_cb=None, prog_cb=None, headers=None, **kargs): # def _complete_cb(self, event): # def _data_cb(self, event): # class Singleton(object): # class EmcExec(object): # class EmcUrl(ecore_con.Url): , which may include functions, classes, or code. Output only the next line.
_scan_folder(os.path.join(utils.emc_base_dir, 'plugins'))
Here is a snippet: <|code_start|># # 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 __future__ import absolute_import, print_function def DBG(msg): # print('MPRIS2: %s' % msg) pass ROOT_IFACE = "org.mpris.MediaPlayer2" PLAYER_IFACE = "org.mpris.MediaPlayer2.Player" <|code_end|> . Write the next line using the current file imports: import dbus import dbus.service import epymc.input_events as input_events import epymc.events as events import epymc.mediaplayer as mediaplayer import epymc.utils as utils import epymc.gui as gui from efl import ecore from efl.dbus_mainloop import DBusEcoreMainLoop from epymc.modules import EmcModule from .dbus_helper import DBusServiceObjectWithProps, dbus_property and context from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() # # Path: epymc/plugins/input_mpris2/dbus_helper.py # class DBusServiceObjectWithProps(dbus.service.Object): # """ TODO doc """ # # def __init__(self, *args, **kargs): # dbus.service.Object.__init__(self, *args, **kargs) # # @staticmethod # def _reflect_on_property(func): # return ' <property name="%s" type="%s" access="%s"/>\n' % \ # (func.__name__, func._dbus_type, func._dbus_access) # # def Introspect(self, object_path, connection): # """Return a string of XML encoding this object's supported interfaces, # methods, signals AND PROPERTIES. # """ # reflection_data = INTROSPECT_DOCTYPE # reflection_data += '<node name="%s">\n' % object_path # # interfaces = self._dbus_class_table[self.__class__.__module__ + '.' + # self.__class__.__name__] # for (name, funcs) in interfaces.items(): # reflection_data += ' <interface name="%s">\n' % (name) # # for func in funcs.values(): # if getattr(func, '_dbus_is_method', False): # reflection_data += self.__class__._reflect_on_method(func) # elif getattr(func, '_dbus_is_signal', False): # reflection_data += self.__class__._reflect_on_signal(func) # elif getattr(func, '_dbus_is_property', False): # reflection_data += self._reflect_on_property(func) # # reflection_data += ' </interface>\n' # # for name in connection.list_exported_child_objects(object_path): # reflection_data += ' <node name="%s"/>\n' % name # # reflection_data += '</node>\n' # # return reflection_data # # @dbus.service.method(dbus.PROPERTIES_IFACE, # in_signature='ss', out_signature='v') # def Get(self, interface_name, property_name): # func = getattr(self, property_name) # if callable(func): # return func() # else: # raise dbus.exceptions.DBusException( # 'interface_name', # 'The object does not implement the %s property' % property_name) # # @dbus.service.method(dbus.PROPERTIES_IFACE, # in_signature='s', out_signature='a{sv}') # def GetAll(self, interface_name): # try: # funcs = self._dbus_class_table[self.__class__.__module__ + '.' + # self.__class__.__name__][interface_name] # except: # raise dbus.exceptions.DBusException( # interface_name, 'The object does not implement this interface') # # props = {} # for (name, func) in funcs.items(): # if getattr(func, '_dbus_is_property', False): # props[func.__name__] = func(self) # # return props # # @dbus.service.method(dbus.PROPERTIES_IFACE, # in_signature='ssv') # def Set(self, interface_name, property_name, new_value): # func = getattr(self, property_name) # setter_name = getattr(func, '_dbus_setter') # setter = getattr(self, setter_name) # if callable(setter): # setter(new_value) # # @dbus.service.signal(dbus.PROPERTIES_IFACE, # signature='sa{sv}as') # def PropertiesChanged(self, interface_name, changed_properties, # invalidated_properties): # pass # # def emit_properties_changed(self, iface, props, invalidated=None): # if invalidated is None: # invalidated = [] # if type(props) is tuple: # propvals = {prop: getattr(self, prop)() for prop in props} # else: # propvals = {props: getattr(self, props)()} # self.PropertiesChanged(iface, propvals, invalidated) # # def dbus_property(dbus_interface, signature, setter=None): # """ TODO doc """ # # def decorator(func): # func._dbus_is_property = True # func._dbus_interface = dbus_interface # func._dbus_type = signature # func._dbus_setter = setter # func._dbus_access = 'readwrite' if setter else 'read' # return func # # return decorator , which may include functions, classes, or code. Output only the next line.
class MPRIS2Module(EmcModule):
Here is a snippet: <|code_start|># This Python file uses the following encoding: utf-8 # # Copyright (C) 2010-2018 Davide Andreoli <dave@gurumeditation.it> # # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function def DBG(msg): # print('SSAVER: %s' % msg) pass <|code_end|> . Write the next line using the current file imports: import time, re import epymc.ini as ini import epymc.gui as gui import epymc.config_gui as cgui import epymc.events as events from efl.ecore import Timer, Exe, ECORE_CALLBACK_RENEW from epymc.modules import EmcModule and context from other files: # Path: epymc/modules.py # class EmcModule(object): # name = '' # label = '' # icon = '' # info = '' # # def __init__(self): # pass # # def __shutdown__(self): # pass # # def __restart__(self): # self.__shutdown__() # self.__init__() , which may include functions, classes, or code. Output only the next line.
class ScreenSaver(EmcModule):
Based on the snippet: <|code_start|>#!/usr/bin/env python # This Python file uses the following encoding: utf-8 # # Copyright (C) 2010-2018 Davide Andreoli <dave@gurumeditation.it> # # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_VIDEO_LIST = 1 ST_PLAY = 2 base = 'http://www.zapiks.com/' <|code_end|> , predict the immediate next line with the help of imports: import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Next line prediction: <|code_start|>ST_PLAY = 2 base = 'http://www.zapiks.com/' STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: b = base u = '/popular_1.php' d = os.path.dirname(__file__) item_add(ST_VIDEO_LIST, 'Brand New Videos', b + 'p_1', action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Surf', b + 'surf_' + u, poster=os.path.join(d, 'surf.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Snowboard', b + 'snowboard_' + u, poster=os.path.join(d, 'snowboard.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Mountain Bike', b + 'mountainbike_' + u, poster=os.path.join(d, 'vtt.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Bmx', b + 'bmx_' + u, poster=os.path.join(d, 'bmx.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Skate', b + 'skate_' + u, poster=os.path.join(d, 'skate.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Ski', b + 'ski_' + u, poster=os.path.join(d, 'ski.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Kite', b + 'kite_' + u, poster=os.path.join(d, 'zapiks.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Wakeboard', b + 'wake_' + u, poster=os.path.join(d, 'zapiks.png'), action=ACT_FOLDER) item_add(ST_VIDEO_LIST, 'Other', b + 'other_' + u, poster=os.path.join(d, 'zapiks.png'), action=ACT_FOLDER) # the page for each category elif STATE == ST_VIDEO_LIST: # soup = fetch_url(URL, parser='bs4') # this line work, but: # the zapiks page have an erroneous auto closing div tag # so wee need this hack to let bs4 correctly parse the html <|code_end|> . Use current file imports: (import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
html = fetch_url(URL)
Based on the snippet: <|code_start|> views = int(views.strip().replace('Views', '').replace(' ', '')) try: likes = int(video.find('span', class_='teaser-counter-likes').string.strip()) except: likes = 0 info = '<title>{}</title><br>' \ '<small><name>{}</name> {} <name>/ {} {}</name></small><br>' \ '<small><success>{} {}</success> <name>/</> ' \ '<info>{} {}</info></small><br>' \ '{}'.format(title, _('user'), user, _('uploaded'), relative_date(uploaded), views, ngettext('view', 'views', views), likes, ngettext('like', 'likes', likes), intro.replace('&amp;', '&') if intro else '') item_add(ST_PLAY, title, url, poster=thumb, info=info, icon='icon/play') except: traceback.print_exc() try: cur_page = soup.find('li', class_='active') next_page = cur_page.next_sibling.a['href'] item_add(ST_VIDEO_LIST, 'More items...', 'http://www.zapiks.com' + next_page, icon='icon/next', action=ACT_MORE) except: pass # extract the video link from the video page elif STATE == ST_PLAY: video_url = call_ydl(URL) <|code_end|> , predict the immediate next line with the help of imports: import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(video_url)
Predict the next line for this snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_VIDEO_LIST = 1 ST_PLAY = 2 base = 'http://www.zapiks.com/' STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: b = base u = '/popular_1.php' d = os.path.dirname(__file__) <|code_end|> with the help of current file imports: import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
item_add(ST_VIDEO_LIST, 'Brand New Videos', b + 'p_1', action=ACT_FOLDER)
Given the code snippet: <|code_start|> views = list(video.find('span', class_='teaser-counter').strings)[0] views = int(views.strip().replace('Views', '').replace(' ', '')) try: likes = int(video.find('span', class_='teaser-counter-likes').string.strip()) except: likes = 0 info = '<title>{}</title><br>' \ '<small><name>{}</name> {} <name>/ {} {}</name></small><br>' \ '<small><success>{} {}</success> <name>/</> ' \ '<info>{} {}</info></small><br>' \ '{}'.format(title, _('user'), user, _('uploaded'), relative_date(uploaded), views, ngettext('view', 'views', views), likes, ngettext('like', 'likes', likes), intro.replace('&amp;', '&') if intro else '') item_add(ST_PLAY, title, url, poster=thumb, info=info, icon='icon/play') except: traceback.print_exc() try: cur_page = soup.find('li', class_='active') next_page = cur_page.next_sibling.a['href'] item_add(ST_VIDEO_LIST, 'More items...', 'http://www.zapiks.com' + next_page, icon='icon/next', action=ACT_MORE) except: pass # extract the video link from the video page elif STATE == ST_PLAY: <|code_end|> , generate the next line using the imports in this file: import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
video_url = call_ydl(URL)
Using the snippet: <|code_start|> # the page for each category elif STATE == ST_VIDEO_LIST: # soup = fetch_url(URL, parser='bs4') # this line work, but: # the zapiks page have an erroneous auto closing div tag # so wee need this hack to let bs4 correctly parse the html html = fetch_url(URL) soup = BeautifulSoup(html.replace('/>', '>'), 'lxml') videos = soup.findAll('a', class_='teaser-video-content') for video in videos: try: url = 'http://www.zapiks.com' + video['href'] title = video.find('span', class_='teaser-title').string.strip() thumb = video.find('div', class_='teaser-thumbnail')['style'] thumb = thumb.replace("background-image : url('", '').replace("')", '') intro = video.find('div', class_='teaser-intro').string user = video.find('span', class_='teaser-user').string.strip().replace('from ', '') uploaded = video.find('span', class_='teaser-date')['datetime'] views = list(video.find('span', class_='teaser-counter').strings)[0] views = int(views.strip().replace('Views', '').replace(' ', '')) try: likes = int(video.find('span', class_='teaser-counter-likes').string.strip()) except: likes = 0 info = '<title>{}</title><br>' \ '<small><name>{}</name> {} <name>/ {} {}</name></small><br>' \ '<small><success>{} {}</success> <name>/</> ' \ '<info>{} {}</info></small><br>' \ '{}'.format(title, <|code_end|> , determine the next line of code. You have imports: import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
_('user'), user, _('uploaded'), relative_date(uploaded),
Given snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division ST_HOME = 0 ST_VIDEO_LIST = 1 ST_PLAY = 2 base = 'http://www.zapiks.com/' STATE, URL = state_get() # this is the first page, show fixed categories if STATE == ST_HOME: b = base u = '/popular_1.php' d = os.path.dirname(__file__) <|code_end|> , continue by predicting the next line. Consider current file imports: import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): which might include code, classes, or functions. Output only the next line.
item_add(ST_VIDEO_LIST, 'Brand New Videos', b + 'p_1', action=ACT_FOLDER)
Next line prediction: <|code_start|> url = 'http://www.zapiks.com' + video['href'] title = video.find('span', class_='teaser-title').string.strip() thumb = video.find('div', class_='teaser-thumbnail')['style'] thumb = thumb.replace("background-image : url('", '').replace("')", '') intro = video.find('div', class_='teaser-intro').string user = video.find('span', class_='teaser-user').string.strip().replace('from ', '') uploaded = video.find('span', class_='teaser-date')['datetime'] views = list(video.find('span', class_='teaser-counter').strings)[0] views = int(views.strip().replace('Views', '').replace(' ', '')) try: likes = int(video.find('span', class_='teaser-counter-likes').string.strip()) except: likes = 0 info = '<title>{}</title><br>' \ '<small><name>{}</name> {} <name>/ {} {}</name></small><br>' \ '<small><success>{} {}</success> <name>/</> ' \ '<info>{} {}</info></small><br>' \ '{}'.format(title, _('user'), user, _('uploaded'), relative_date(uploaded), views, ngettext('view', 'views', views), likes, ngettext('like', 'likes', likes), intro.replace('&amp;', '&') if intro else '') item_add(ST_PLAY, title, url, poster=thumb, info=info, icon='icon/play') except: traceback.print_exc() try: cur_page = soup.find('li', class_='active') next_page = cur_page.next_sibling.a['href'] <|code_end|> . Use current file imports: (import os import traceback from bs4 import BeautifulSoup from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, relative_date, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_VIDEO_LIST, 'More items...', 'http://www.zapiks.com' + next_page, icon='icon/next', action=ACT_MORE)
Continue the code snippet: <|code_start|># Copyright (C) 2010-2018 Davide Andreoli <dave@gurumeditation.it> # # This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division API_BASE = 'http://api.porn.com' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_SEARCH = 1 ST_CATEGORIES = 2 ST_CHANNELS = 3 ST_VIDEO_LIST = 4 ST_PLAY = 69 <|code_end|> . Use current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, or code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Using the snippet: <|code_start|> url = API_BASE + '/videos/find.json?order=date&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_VIDEO_LIST, 'Recently Added', url, action=ACT_FOLDER) url = API_BASE + '/videos/find.json?order=views&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_VIDEO_LIST, 'Most Viewed', url, action=ACT_FOLDER) url = API_BASE + '/videos/find.json?order=rating&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_VIDEO_LIST, 'Top Rated', url, action=ACT_FOLDER) # url = API_BASE + '/videos/find.json?order=favorites&limit={}&page=1'.format(ITEMS_PER_PAGE) # item_add(ST_VIDEO_LIST, 'Top Favorites', url, action=ACT_FOLDER) url = API_BASE + '/categories/find.json' item_add(ST_CATEGORIES, 'Categories', url, action=ACT_FOLDER) url = API_BASE + '/channels/find.json?order=rating&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_CHANNELS, 'Channels - Top Rated', url, action=ACT_FOLDER) url = API_BASE + '/channels/find.json?order=views&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_CHANNELS, 'Channels - Most Viewed', url, action=ACT_FOLDER) url = API_BASE + '/channels/find.json?order=favorites&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_CHANNELS, 'Channels - Top Favorites', url, action=ACT_FOLDER) # search query from virtual keyboard elif STATE == ST_SEARCH: url = API_BASE + '/videos/find.json?' + \ url_encode({'search': URL, 'limit': ITEMS_PER_PAGE, 'order': 'rating'}) <|code_end|> , determine the next line of code. You have imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
data = fetch_url(url, parser='json')
Given the following code snippet before the placeholder: <|code_start|> # videos list elif STATE == ST_VIDEO_LIST: data = fetch_url(URL, parser='json') build_video_list(URL, data) # categories list elif STATE == ST_CATEGORIES: data = fetch_url(URL, parser='json') for cat in data['result']: url = API_BASE + '/videos/find.json?' + \ url_encode({'tags': cat, 'limit': ITEMS_PER_PAGE, 'order': 'date'}) item_add(ST_VIDEO_LIST, cat, url + '&page=1') # channels list elif STATE == ST_CHANNELS: data = fetch_url(URL, parser='json') for ch in data['result']: url = API_BASE + '/videos/find.json?' + \ url_encode({'channel': ch['name'], 'limit': ITEMS_PER_PAGE, 'order': 'date'}) title = '{} ({} vids)'.format(ch['name'], ch['num_videos']) item_add(ST_VIDEO_LIST, title, url + '&page=1') build_next_page_item(URL, data['count'], ST_CHANNELS) # play (using youtube-dl) elif STATE == ST_PLAY: url = call_ydl(URL) <|code_end|> , predict the next line using imports from the current file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(url) if url else report_error('Video not found')
Next line prediction: <|code_start|>ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_SEARCH = 1 ST_CATEGORIES = 2 ST_CHANNELS = 3 ST_VIDEO_LIST = 4 ST_PLAY = 69 STATE, URL = state_get() def build_video_list(url, data): for video in data['result']: title = video['title'] or 'Untitled video' info = '<title>{}</title> <small>{}</small><br>' \ '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.1f}/5</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>Actors:</name> {}<br>' \ '<name>Tags:</name> {}</small>'.format( title, seconds_to_duration(video['duration']), _('uploaded'), relative_date(video['active_date']), video['views'], ngettext('view', 'views', video['views']), _('rated'), video['rating'], video['ratings'], ngettext('like', 'likes', video['ratings']), ', '.join(video['actors']), ', '.join(video['tags'])) <|code_end|> . Use current file imports: (from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH) and context including class names, function names, or small code snippets from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info)
Given the code snippet: <|code_start|> # videos list elif STATE == ST_VIDEO_LIST: data = fetch_url(URL, parser='json') build_video_list(URL, data) # categories list elif STATE == ST_CATEGORIES: data = fetch_url(URL, parser='json') for cat in data['result']: url = API_BASE + '/videos/find.json?' + \ url_encode({'tags': cat, 'limit': ITEMS_PER_PAGE, 'order': 'date'}) item_add(ST_VIDEO_LIST, cat, url + '&page=1') # channels list elif STATE == ST_CHANNELS: data = fetch_url(URL, parser='json') for ch in data['result']: url = API_BASE + '/videos/find.json?' + \ url_encode({'channel': ch['name'], 'limit': ITEMS_PER_PAGE, 'order': 'date'}) title = '{} ({} vids)'.format(ch['name'], ch['num_videos']) item_add(ST_VIDEO_LIST, title, url + '&page=1') build_next_page_item(URL, data['count'], ST_CHANNELS) # play (using youtube-dl) elif STATE == ST_PLAY: <|code_end|> , generate the next line using the imports in this file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
url = call_ydl(URL)
Using the snippet: <|code_start|> # videos list elif STATE == ST_VIDEO_LIST: data = fetch_url(URL, parser='json') build_video_list(URL, data) # categories list elif STATE == ST_CATEGORIES: data = fetch_url(URL, parser='json') for cat in data['result']: url = API_BASE + '/videos/find.json?' + \ url_encode({'tags': cat, 'limit': ITEMS_PER_PAGE, 'order': 'date'}) item_add(ST_VIDEO_LIST, cat, url + '&page=1') # channels list elif STATE == ST_CHANNELS: data = fetch_url(URL, parser='json') for ch in data['result']: url = API_BASE + '/videos/find.json?' + \ url_encode({'channel': ch['name'], 'limit': ITEMS_PER_PAGE, 'order': 'date'}) title = '{} ({} vids)'.format(ch['name'], ch['num_videos']) item_add(ST_VIDEO_LIST, title, url + '&page=1') build_next_page_item(URL, data['count'], ST_CHANNELS) # play (using youtube-dl) elif STATE == ST_PLAY: url = call_ydl(URL) <|code_end|> , determine the next line of code. You have imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(url) if url else report_error('Video not found')
Here is a snippet: <|code_start|># # 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 __future__ import absolute_import, print_function, unicode_literals, division API_BASE = 'http://api.porn.com' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_SEARCH = 1 ST_CATEGORIES = 2 ST_CHANNELS = 3 ST_VIDEO_LIST = 4 ST_PLAY = 69 STATE, URL = state_get() def build_video_list(url, data): for video in data['result']: title = video['title'] or 'Untitled video' info = '<title>{}</title> <small>{}</small><br>' \ '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.1f}/5</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>Actors:</name> {}<br>' \ '<name>Tags:</name> {}</small>'.format( <|code_end|> . Write the next line using the current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may include functions, classes, or code. Output only the next line.
title, seconds_to_duration(video['duration']),
Given the following code snippet before the placeholder: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division API_BASE = 'http://api.porn.com' ITEMS_PER_PAGE = 50 ST_HOME = 0 ST_SEARCH = 1 ST_CATEGORIES = 2 ST_CHANNELS = 3 ST_VIDEO_LIST = 4 ST_PLAY = 69 STATE, URL = state_get() def build_video_list(url, data): for video in data['result']: title = video['title'] or 'Untitled video' info = '<title>{}</title> <small>{}</small><br>' \ '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.1f}/5</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>Actors:</name> {}<br>' \ '<name>Tags:</name> {}</small>'.format( title, seconds_to_duration(video['duration']), <|code_end|> , predict the next line using imports from the current file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
_('uploaded'), relative_date(video['active_date']),
Given the code snippet: <|code_start|> item_add(ST_PLAY, 'Play a Random video', url, icon='icon/play') url = API_BASE + '/videos/find.json?order=date&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_VIDEO_LIST, 'Recently Added', url, action=ACT_FOLDER) url = API_BASE + '/videos/find.json?order=views&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_VIDEO_LIST, 'Most Viewed', url, action=ACT_FOLDER) url = API_BASE + '/videos/find.json?order=rating&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_VIDEO_LIST, 'Top Rated', url, action=ACT_FOLDER) # url = API_BASE + '/videos/find.json?order=favorites&limit={}&page=1'.format(ITEMS_PER_PAGE) # item_add(ST_VIDEO_LIST, 'Top Favorites', url, action=ACT_FOLDER) url = API_BASE + '/categories/find.json' item_add(ST_CATEGORIES, 'Categories', url, action=ACT_FOLDER) url = API_BASE + '/channels/find.json?order=rating&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_CHANNELS, 'Channels - Top Rated', url, action=ACT_FOLDER) url = API_BASE + '/channels/find.json?order=views&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_CHANNELS, 'Channels - Most Viewed', url, action=ACT_FOLDER) url = API_BASE + '/channels/find.json?order=favorites&limit={}&page=1'.format(ITEMS_PER_PAGE) item_add(ST_CHANNELS, 'Channels - Top Favorites', url, action=ACT_FOLDER) # search query from virtual keyboard elif STATE == ST_SEARCH: url = API_BASE + '/videos/find.json?' + \ <|code_end|> , generate the next line using the imports in this file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
url_encode({'search': URL, 'limit': ITEMS_PER_PAGE, 'order': 'rating'})
Predict the next line after this snippet: <|code_start|> video['views'], ngettext('view', 'views', video['views']), _('rated'), video['rating'], video['ratings'], ngettext('like', 'likes', video['ratings']), ', '.join(video['actors']), ', '.join(video['tags'])) item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info) build_next_page_item(url, data['count'], ST_VIDEO_LIST) def build_next_page_item(url, total, next_state): # NOTE: this assume 'page=X' is ALWAYS the last param!! don't forget it! num_pages = int(total / ITEMS_PER_PAGE) + 1 url, cur_page = url.split('page=') next_page = int(cur_page) + 1 if next_page <= num_pages: url += 'page=%d' % (next_page) title = 'Next page ({} of {})'.format(next_page, num_pages) item_add(next_state, title, url, action=ACT_MORE) # the first page, show fixed categories if STATE == ST_HOME: item_add(ST_SEARCH, 'Search videos', 'search', action=ACT_SEARCH) url = 'http://www.porn.com/random' item_add(ST_PLAY, 'Play a Random video', url, icon='icon/play') url = API_BASE + '/videos/find.json?order=date&limit={}&page=1'.format(ITEMS_PER_PAGE) <|code_end|> using the current file's imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_VIDEO_LIST, 'Recently Added', url, action=ACT_FOLDER)
Given snippet: <|code_start|>def build_video_list(url, data): for video in data['result']: title = video['title'] or 'Untitled video' info = '<title>{}</title> <small>{}</small><br>' \ '<small><name>{}</name> {}<br>' \ '<success>{} {}</success> <name>/</name> ' \ '<warning>{} {:.1f}/5</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>Actors:</name> {}<br>' \ '<name>Tags:</name> {}</small>'.format( title, seconds_to_duration(video['duration']), _('uploaded'), relative_date(video['active_date']), video['views'], ngettext('view', 'views', video['views']), _('rated'), video['rating'], video['ratings'], ngettext('like', 'likes', video['ratings']), ', '.join(video['actors']), ', '.join(video['tags'])) item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info) build_next_page_item(url, data['count'], ST_VIDEO_LIST) def build_next_page_item(url, total, next_state): # NOTE: this assume 'page=X' is ALWAYS the last param!! don't forget it! num_pages = int(total / ITEMS_PER_PAGE) + 1 url, cur_page = url.split('page=') next_page = int(cur_page) + 1 if next_page <= num_pages: url += 'page=%d' % (next_page) title = 'Next page ({} of {})'.format(next_page, num_pages) <|code_end|> , continue by predicting the next line. Consider current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): which might include code, classes, or functions. Output only the next line.
item_add(next_state, title, url, action=ACT_MORE)
Predict the next line for this snippet: <|code_start|> '<warning>{} {:.1f}/5</warning> <name>/</name> ' \ '<info>{} {}</info><br>' \ '<name>Actors:</name> {}<br>' \ '<name>Tags:</name> {}</small>'.format( title, seconds_to_duration(video['duration']), _('uploaded'), relative_date(video['active_date']), video['views'], ngettext('view', 'views', video['views']), _('rated'), video['rating'], video['ratings'], ngettext('like', 'likes', video['ratings']), ', '.join(video['actors']), ', '.join(video['tags'])) item_add(ST_PLAY, title, video['url'], poster=video['thumb'], info=info) build_next_page_item(url, data['count'], ST_VIDEO_LIST) def build_next_page_item(url, total, next_state): # NOTE: this assume 'page=X' is ALWAYS the last param!! don't forget it! num_pages = int(total / ITEMS_PER_PAGE) + 1 url, cur_page = url.split('page=') next_page = int(cur_page) + 1 if next_page <= num_pages: url += 'page=%d' % (next_page) title = 'Next page ({} of {})'.format(next_page, num_pages) item_add(next_state, title, url, action=ACT_MORE) # the first page, show fixed categories if STATE == ST_HOME: <|code_end|> with the help of current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, report_error, \ seconds_to_duration, relative_date, url_encode, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
item_add(ST_SEARCH, 'Search videos', 'search', action=ACT_SEARCH)
Based on the snippet: <|code_start|># This file is part of EpyMC, an EFL based Media Center written in Python. # # 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 __future__ import absolute_import, print_function, unicode_literals, division API_KEY = '19eef197b81231dff0fd1a14a8d5f863' # Key of the user DaveMDS API_BASE = 'http://api.themoviedb.org/3' IMG_BASE = 'http://image.tmdb.org/t/p' # this should be queried and cached :/ ST_HOME = 0 ST_SEARCH = 1 ST_MOVIES_LIST = 2 ST_MOVIE_INFO = 3 ST_CAST_LIST = 4 ST_NONE = 9 ST_PLAY_YOUTUBE = 10 <|code_end|> , predict the immediate next line with the help of imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
STATE, URL = state_get()
Given the code snippet: <|code_start|># 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 __future__ import absolute_import, print_function, unicode_literals, division API_KEY = '19eef197b81231dff0fd1a14a8d5f863' # Key of the user DaveMDS API_BASE = 'http://api.themoviedb.org/3' IMG_BASE = 'http://image.tmdb.org/t/p' # this should be queried and cached :/ ST_HOME = 0 ST_SEARCH = 1 ST_MOVIES_LIST = 2 ST_MOVIE_INFO = 3 ST_CAST_LIST = 4 ST_NONE = 9 ST_PLAY_YOUTUBE = 10 STATE, URL = state_get() LANG = language_get() def v3_request(url, lang=None): if '?' not in url: url += '?' url = API_BASE + url + '&api_key=' + API_KEY + '&language=' + (lang or LANG) # print("API REQUEST: " + url) <|code_end|> , generate the next line using the imports in this file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (functions, classes, or occasionally code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
return fetch_url(url, parser='json')
Given the following code snippet before the placeholder: <|code_start|> _('Source'), video['site'], _('Quality'), video['size']) item_add(ST_PLAY_YOUTUBE, video['name'], url, info=info, poster=poster, icon='icon/play') else: item_add(ST_NONE, _('No trailers available'), None, poster=poster, icon='icon/play', action=ACT_NONE) # cast item_add(ST_CAST_LIST, _('Cast'), '/movie/%d/credits' % data['id'], poster=poster, icon='icon/head') ################################################################################ # Cast list ################################################################################ elif STATE == ST_CAST_LIST: data = v3_request(URL) for c in data['cast']: title = '{} <i>{} {}</i>'.format( c['name'], _('as'), c['character']) poster = full_img_url(c['profile_path'], size='h632') item_add(ST_NONE, title, 'url', poster=poster, action=ACT_NONE) ################################################################################ # Play youtube video ################################################################################ elif STATE == ST_PLAY_YOUTUBE: real_url = call_ydl(URL) <|code_end|> , predict the next line using imports from the current file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
play_url(real_url)
Predict the next line after this snippet: <|code_start|>IMG_BASE = 'http://image.tmdb.org/t/p' # this should be queried and cached :/ ST_HOME = 0 ST_SEARCH = 1 ST_MOVIES_LIST = 2 ST_MOVIE_INFO = 3 ST_CAST_LIST = 4 ST_NONE = 9 ST_PLAY_YOUTUBE = 10 STATE, URL = state_get() LANG = language_get() def v3_request(url, lang=None): if '?' not in url: url += '?' url = API_BASE + url + '&api_key=' + API_KEY + '&language=' + (lang or LANG) # print("API REQUEST: " + url) return fetch_url(url, parser='json') def full_img_url(img, size='w500'): return (IMG_BASE + '/' + size + img) if img else None def movie_item(movie_data): title = movie_data['title'] poster = full_img_url(movie_data['poster_path']) url = '/movie/%d?append_to_response=credits,videos' % movie_data['id'] <|code_end|> using the current file's imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(ST_MOVIE_INFO, title, url, poster=poster)
Predict the next line after this snippet: <|code_start|> _('Language'), video['iso_639_1'], _('Source'), video['site'], _('Quality'), video['size']) item_add(ST_PLAY_YOUTUBE, video['name'], url, info=info, poster=poster, icon='icon/play') else: item_add(ST_NONE, _('No trailers available'), None, poster=poster, icon='icon/play', action=ACT_NONE) # cast item_add(ST_CAST_LIST, _('Cast'), '/movie/%d/credits' % data['id'], poster=poster, icon='icon/head') ################################################################################ # Cast list ################################################################################ elif STATE == ST_CAST_LIST: data = v3_request(URL) for c in data['cast']: title = '{} <i>{} {}</i>'.format( c['name'], _('as'), c['character']) poster = full_img_url(c['profile_path'], size='h632') item_add(ST_NONE, title, 'url', poster=poster, action=ACT_NONE) ################################################################################ # Play youtube video ################################################################################ elif STATE == ST_PLAY_YOUTUBE: <|code_end|> using the current file's imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and any relevant context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
real_url = call_ydl(URL)
Based on the snippet: <|code_start|> def next_page_item(url, data, next_state): if data['page'] < data['total_pages']: page = data['page'] if '&page=' in url: next_url = url.replace('&page=%d' % (page), '&page=%d' % (page + 1)) else: if not '?' in url: url += '?' next_url = url + '&page=%d' % (page + 1) text = _('Load more results (page {0} of {1})').format(page, data['total_pages']) item_add(next_state, text, next_url, action=ACT_MORE) ################################################################################ # home page ################################################################################ if STATE == ST_HOME: item_add(ST_SEARCH, _('Search movies'), 'search', action=ACT_SEARCH) item_add(ST_MOVIES_LIST, _('Popular movies'), '/movie/popular', action=ACT_FOLDER) item_add(ST_MOVIES_LIST, _('Top rated movies'), '/movie/top_rated', action=ACT_FOLDER) item_add(ST_MOVIES_LIST, _('Upcoming movies'), '/movie/upcoming', action=ACT_FOLDER) item_add(ST_MOVIES_LIST, _('Now playing movies'), '/movie/now_playing', action=ACT_FOLDER) ################################################################################ # search movies ################################################################################ elif STATE == ST_SEARCH: if '&page=' not in URL: <|code_end|> , predict the immediate next line with the help of imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (classes, functions, sometimes code) from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
data = v3_request('/search/movie?' + url_encode({'query': URL}))
Using the snippet: <|code_start|># # 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 __future__ import absolute_import, print_function, unicode_literals, division API_KEY = '19eef197b81231dff0fd1a14a8d5f863' # Key of the user DaveMDS API_BASE = 'http://api.themoviedb.org/3' IMG_BASE = 'http://image.tmdb.org/t/p' # this should be queried and cached :/ ST_HOME = 0 ST_SEARCH = 1 ST_MOVIES_LIST = 2 ST_MOVIE_INFO = 3 ST_CAST_LIST = 4 ST_NONE = 9 ST_PLAY_YOUTUBE = 10 STATE, URL = state_get() <|code_end|> , determine the next line of code. You have imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context (class names, function names, or code) available: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
LANG = language_get()
Predict the next line for this snippet: <|code_start|> year = data['release_date'][:4] except: year = '' try: directors = [d['name'] for d in data['credits']['crew'] if d['job'] == 'Director'] except: directors = [_('Unknown')] try: casts = [d['name'] for i, d in enumerate(data['credits']['cast']) if i < 5] except: casts = [_('Unknown')] info = '<title>{}</title> <small>({} {})</small><br>' \ '<small><name>{}:</name> {}</small><br>' \ '<small><name>{}:</name> {}</small><br>' \ '<small><name>{}:</name> {}</small><br>' \ '<small><name>{}:</name> {}</small><br>' \ '<small><name>{}:</name> {}/10 ({} {})</small><br>' \ '<small><name>{}:</name> {}</small><br>' \ '{}'.format(title, country, year, _('Director'), ', '.join(directors), _('Cast'), ', '.join(casts), _('Original title'), original, _('Genres'), genres, _('Rating'), data['vote_average'], data['vote_count'], _('votes'), _('Released'), data['release_date'], overview) item_add(ST_NONE, title, None, poster=poster, <|code_end|> with the help of current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): , which may contain function names, class names, or code. Output only the next line.
info=info, icon='icon/info', action=ACT_NONE)
Given snippet: <|code_start|> def full_img_url(img, size='w500'): return (IMG_BASE + '/' + size + img) if img else None def movie_item(movie_data): title = movie_data['title'] poster = full_img_url(movie_data['poster_path']) url = '/movie/%d?append_to_response=credits,videos' % movie_data['id'] item_add(ST_MOVIE_INFO, title, url, poster=poster) def next_page_item(url, data, next_state): if data['page'] < data['total_pages']: page = data['page'] if '&page=' in url: next_url = url.replace('&page=%d' % (page), '&page=%d' % (page + 1)) else: if not '?' in url: url += '?' next_url = url + '&page=%d' % (page + 1) text = _('Load more results (page {0} of {1})').format(page, data['total_pages']) item_add(next_state, text, next_url, action=ACT_MORE) ################################################################################ # home page ################################################################################ if STATE == ST_HOME: item_add(ST_SEARCH, _('Search movies'), 'search', action=ACT_SEARCH) <|code_end|> , continue by predicting the next line. Consider current file imports: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): which might include code, classes, or functions. Output only the next line.
item_add(ST_MOVIES_LIST, _('Popular movies'), '/movie/popular', action=ACT_FOLDER)
Given the following code snippet before the placeholder: <|code_start|> def v3_request(url, lang=None): if '?' not in url: url += '?' url = API_BASE + url + '&api_key=' + API_KEY + '&language=' + (lang or LANG) # print("API REQUEST: " + url) return fetch_url(url, parser='json') def full_img_url(img, size='w500'): return (IMG_BASE + '/' + size + img) if img else None def movie_item(movie_data): title = movie_data['title'] poster = full_img_url(movie_data['poster_path']) url = '/movie/%d?append_to_response=credits,videos' % movie_data['id'] item_add(ST_MOVIE_INFO, title, url, poster=poster) def next_page_item(url, data, next_state): if data['page'] < data['total_pages']: page = data['page'] if '&page=' in url: next_url = url.replace('&page=%d' % (page), '&page=%d' % (page + 1)) else: if not '?' in url: url += '?' next_url = url + '&page=%d' % (page + 1) text = _('Load more results (page {0} of {1})').format(page, data['total_pages']) <|code_end|> , predict the next line using imports from the current file: from epymc.extapi.onlinevideo import api_version, state_get, \ fetch_url, play_url, item_add, call_ydl, url_encode, language_get, \ ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH and context including class names, function names, and sometimes code from other files: # Path: epymc/extapi/onlinevideo.py # ACT_DEFAULT = 0 # ACT_NONE = 1 # ACT_FOLDER = 2 # ACT_MORE = 3 # ACT_PLAY = 4 # ACT_SEARCH = 5 # def state_get(): # def language_get(): # def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT): # def play_url(url): # def report_error(msg): # def local_resource(_file_, res): # def fetch_url(url, headers=None, parser=None): # def ydl_executable(): # def call_ydl(url): # def url_encode(params): # def seconds_to_duration(seconds): # def relative_date(date): # def format_date(date): . Output only the next line.
item_add(next_state, text, next_url, action=ACT_MORE)