Browse Episodes of an remote application (with the keychain)
@Route("/remote/{keychain}", name="oktolab_media_remote_episodes")
@Method("GET")
@Template()
426
public function listRemoteEpisodes(Keychain $keychain)
    {
        $episodes_url = $this->get('bprs_applink')->getApiUrlsForKey(
            $keychain,
            'oktolab_media_api_list_episodes'
        );

        if ($episodes_url) {
            $client = new Client();
            $response = $client->request(
                'GET',
                $episodes_url,
                ['auth' => [$keychain->getUser(), $keychain->getApiKey()]]
            );

            if ($response->getStatusCode() == 200) {
                $info = json_decode(
                    html_entity_decode((string)$response->getBody()), true
                );

                return ['result' => $info, 'keychain' => $keychain];
            }
        }

        return new Response('', Response::HTTP_BAD_REQUEST);
    }
36326
public function index()
    {
        //  Decode the token
        $oUri     = Factory::service('Uri');
        $ids      = $oUri->segment(3);
        $hash     = $oUri->segment(4);
        $filename = urldecode($oUri->segment(5));

        if ($ids && $hash) {

            //  Check the hash
            $oCdn    = Factory::service('Cdn', 'nails/module-cdn');
            $objects = $oCdn->verifyUrlServeZippedHash($hash, $ids, $filename);

            if ($objects) {

                //  Define the cache file
                $this->cdnCacheFile = 'cdn-zip-' . $hash . '.zip';

                /**
                 * Check the request headers; avoid hitting the disk at all if possible. If
                 * the Etag matches then send a Not-Modified header and terminate execution.
                 */

                if ($this->serveNotModified($this->cdnCacheFile)) {
                    return;
                }

                // --------------------------------------------------------------------------

                /**
                 * The browser does not have a local cache (or it's out of date) check the cache
                 * to see if this image has been processed already; serve it up if it has.
                 */

                if (file_exists($this->cdnCacheDir . $this->cdnCacheFile)) {

                    $this->serveFromCache($this->cdnCacheFile);

                } else {

                    /**
                     * Cache object does not exist, fetch the originals, zip them and save a
                     * version in the cache bucket..
                     *
                     * Fetch the files to use, if any one doesn't exist any more then this zip
                     * file should fall over.
                     */

                    $usefiles   = [];
                    $useBuckets = false;
                    $prevBucket = '';

                    foreach ($objects as $obj) {

                        $temp           = new stdClass();
                        $temp->path     = $oCdn->objectLocalPath($obj->id);
                        $temp->filename = $obj->file->name->human;
                        $temp->bucket   = $obj->bucket->label;

                        if (!$temp->path) {
                            $this->serveBadSrc( [
                                'error' => 'Object "' . $obj->filename . '" does not exist'
                            ] );
                        }

                        if (!$useBuckets && $prevBucket && $prevBucket !== $obj->bucket->id) {
                            $useBuckets = true;
                        }

                        $prevBucket = $obj->bucket->id;
                        $usefiles[] = $temp;
                    }

                    // --------------------------------------------------------------------------

                    //  Time to start Zipping!
                    $this->load->library('zip');

                    //  Save to the zip
                    foreach ($usefiles as $file) {

                        $name = $useBuckets ? $file->bucket . '/' . $file->filename : $file->filename;
                        $this->zip->add_data($name, file_get_contents($file->path));
                    }

                    //  Save the Zip to the cache directory
                    $this->zip->archive($this->cdnCacheDir . $this->cdnCacheFile);

                    //  Set all the appropriate headers
                    if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== false) {

                        header('Content-Disposition: attachment; filename="' . $filename . '"');
                        header('Expires: 0');
                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                        header("Content-Transfer-Encoding: binary");
                        header('Pragma: public');

                    } else {

                        header('Content-Disposition: attachment; filename="' . $filename . '"');
                        header("Content-Transfer-Encoding: binary");
                        header('Expires: 0');
                        header('Pragma: no-cache');
                    }

                    //  Serve to the people
                    $this->serveFromCache($this->cdnCacheFile, null, false);
                }

            } else {
                $this->serveBadSrc([
                    'error' => 'Could not verify token'
                ]);
            }

        } else {
            $this->serveBadSrc( [
                'error' => 'Missing parameters'
            ]);
        }
    }
824896
protected function collectRemotes()
    {
        $remotesResult = $this->command->getRemotes();

        if (count($remotesResult) === 0) {
            throw new \RuntimeException();
        }

        // parse command result
        $results = [];

        foreach ($remotesResult as $result) {
            if (strpos($result, ' ') !== false) {
                list($remote) = explode(' ', $result, 2);

                $results[] = $remote;
            }
        }

        // filter
        $results = array_unique($results);

        // create Remote instances
        $remotes = [];

        foreach ($results as $result) {
            if (strpos($result, "\t") !== false) {
                list($name, $url) = explode("\t", $result, 2);

                $remote = new Remote();
                $remotes[] = $remote->setName($name)->setUrl($url);
            }
        }

        return $remotes;
    }
268353
def get_remote_url(self, remote='origin', cached=True):
        """"""
        if hasattr(self.__class__, '_remote_url') and cached:
            url = self.__class__._remote_url
        else:
            r = self.get_remote(remote)
            try:
                url = list(r.urls)[0]
            except GitCommandError as ex:
                if 'correct access rights' in str(ex):
                    # If ssh is not setup to access this repository
                    cmd = ['git', 'config', '--get', 'remote.%s.url' % r.name]
                    url = Git().execute(cmd)
                else:
                    raise ex
            except AttributeError:
                url = None
            if url is not None and url.startswith('git@'):
                domain = url.split('@')[1].split(':')[0]
                path = url.split(':')[1]
                url = "http://%s/%s" % (domain, path)
        self.__class__._remote_url = url
        return url
1104776
def applet_get(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/get' % object_id, input_params, always_retry=always_retry, **kwargs)
746964
def query_series_episodes(self, id, absolute_number=None, aired_season=None, aired_episode=None, dvd_season=None,
                              dvd_episode=None, imdb_id=None, page=1):
        """"""
        # perform the request
        params = {'absoluteNumber': absolute_number, 'airedSeason': aired_season, 'airedEpisode': aired_episode,
                  'dvdSeason': dvd_season, 'dvdEpisode': dvd_episode, 'imdbId': imdb_id, 'page': page}
        r = self.session.get(self.base_url + '/series/{}/episodes/query'.format(id), params=params)
        if r.status_code == 404:
            return None
        r.raise_for_status()

        return r.json()
265170
def get_object(self, queryset=None):
        """"""
        if settings.PODCAST_SINGULAR:
            show = get_object_or_404(Show, id=settings.PODCAST_ID)
        else:
            show = get_object_or_404(Show, slug=self.kwargs['show_slug'])
        obj = get_object_or_404(Episode, show=show, slug=self.kwargs['slug'])
        index = Episode.objects.is_public_or_secret().filter(show=show, pub_date__lt=obj.pub_date).count()
        obj.index = index + 1
        obj.index_next = obj.index + 1
        obj.index_previous = obj.index - 1
        return obj
386653
public function indexAction()
  {
    try
    {
      /* grab selected virtual server node */
      $server = $this->ts3->serverGetSelected();

      /* query virtual server viewer and properties */
      $this->tpl->ts3_details = $server->getInfo(TRUE, TRUE);
      $this->tpl->ts3_viewer  = $server->getViewer(new TeamSpeak3_Viewer_Html("../../../images/viewer/", "../../../images/flags/", TS3WA_FTC));
    }
    catch(Exception $e)
    {
      /* save catched error mesage */
      $this->setLastEvent($e->getMessage(), TRUE);
    }
  }
245000
def breadcrumbs
      return unless show_breadcrumbs?

      content_for(
        :breadcrumbs,
        content_tag(:ol, class: "breadcrumb") do
          concat(content_tag(:li, link_to("Home", root_path)))

          if can_view_resource_index?
            concat(
              content_tag(
                :li, controller_link
              )
            )
          end
        end
      )
    end
446579
public function embedEpisodeAction(Request $request)
    {
        $uniqID = $request->query->get('uniqID');
        $episode = $this->get('oktolab_media')->getEpisode($uniqID);
        return ['episode' => $episode];
    }
883938
def videos_for(items, key, options)
      items.body['items'].map{|item| item['id'] = item[key]['videoId']}

      if options[:parts] == %i(id)
        items
      else
        options[:ids] = items.body['items'].map{|item| item['id']}
        options[:offset] = nil
        get('/youtube/v3/videos', resource_params(options)).tap do |response|
          response.body['nextPageToken'] = items.body['nextPageToken']
        end
      end
    end
871781
public function viewRoutes()
	{
		// variables
		$routes = \Route::getRoutes();
		$array  = [];
		foreach ($routes as /** @var Route */ $route)
		{
			// properties
			$methods = method_exists($route, 'getMethods') ? $route->getMethods() : $route->methods;
			$uri = method_exists($route, 'getUri') ? $route->getUri() : $route->uri;
			$action = $route->getAction()['uses'];

			// data
			$array[] =
			[
				'methods'   => implode('|', $methods),
				'uri'       => $uri,
				'name'      => $route->getName(),
				'action'    => $action instanceof \Closure ? 'Closure' : $action,
				'middleware'=> implode(', ', $route->middleware()),
			];
		}

		vue('sketchpad::help/tools/routes', $array);
	}
1064318
def open_remote(serial_number=-1, server_id=nil, password=nil)
	   Phidgets::FFI::Common.openRemote(@handle, serial_number, server_id, password)
	   true
    end
168491
public function cgetAction(Request $request): View
    {
        $this->requireAuthentication($request);

        return View::create()->setData($this->subscriberListRepository->findAll());
    }
141564
def search(series_name)
      response = self.get("/search/series?name=#{URI::encode(series_name)}")
      return [] unless response["data"]
      case response["data"]
      when Array
        response["data"]
      when Hash
        [response["data"]]
      else
        []
      end
    end
819079
public function loadContentTypeByRemoteId(Request $request)
    {
        return $this->contentTypeService->loadContentTypeByRemoteId(
            $request->query->get('remoteId'),
            Language::ALL
        );
    }
243420
def find_videos_by_playlist(self, playlist_id, page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/playlists/videos.json'
        params = {
            'client_id': self.client_id,
            'playlist_id': playlist_id,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()