Permalink
Browse files

website now pulls new demos for the playlist from a database

  • Loading branch information...
1 parent 46e9484 commit 59dc86d8a27916de9ea3ff0708ea36c952f58377 @wchristian committed Aug 12, 2012
View
Binary file not shown.
View
@@ -0,0 +1 @@
+db: development
View
@@ -0,0 +1,4 @@
+development:
+ dsn: "dbi:mysql:host=localhost;database=scenefinity"
+ user: "scenefinity"
+ password: "scenefinity"
View
@@ -13,9 +13,7 @@ use Web::Simple;
use Web::SimpleX::Helper::ActionWithRender qw' mm action ';
use File::ShareDir::ProjectDistDir 'dist_dir';
use Text::Xslate;
-use JSON qw' from_json to_json ';
-use HTTP::Tiny;
-use Data::Dumper;
+use JSON 'to_json';
use YAML 'Load';
use List::Util qw( shuffle );
use Web::Scenefinity::Schema;
@@ -53,35 +51,10 @@ sub dispatch_request {
sub default_view { "Xslate" }
-sub jget {
- my ( $url ) = @_;
- my $res = HTTP::Tiny->new->get( $url );
- die Dumper( $res ) unless $res->{success};
- return from_json( $res->{content} );
-}
-
-sub author_all_videos {
- my ( $author ) = @_;
- my $base =
- "http://gdata.youtube.com/feeds/api/videos?author=%s&v=2&format=5&start-index=%d&max-results=%d&alt=json";
- my @videos;
- my $i = 1;
- while ( 1 ) {
- my $all = jget sprintf $base, $author, $i, 50;
- last if !$all->{feed}{entry};
- push @videos, @{ $all->{feed}{entry} };
- $i += 50;
- }
- return @videos;
-}
-
sub more_demos {
- my @videos = author_all_videos( "Annikras" );
- @videos = shuffle @videos;
- @videos = grep $_, @videos[ 0 .. 9 ];
- my @ids = map $_->{id}{'$t'}, @videos;
- $_ =~ s/.*video:(.*)/$1/ for @ids;
-
+ my ( $self ) = @_;
+ my @videos = $self->db->resultset( 'Video' )->rand( 10 );
+ my @ids = map $_->yt_id, @videos;
return \@ids;
}
@@ -0,0 +1,14 @@
+use strictures;
+
+package Web::Scenefinity::Schema::Result::Video;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table( 'video' );
+__PACKAGE__->add_columns(
+ video_id => { data_type => 'integer', is_auto_increment => 1 },
+ yt_id => { data_type => 'text' },
+);
+__PACKAGE__->set_primary_key( 'video_id' );
+__PACKAGE__->add_unique_constraint( ["yt_id"] );
+
+1;
@@ -0,0 +1,11 @@
+use strictures;
+
+package Web::Scenefinity::Schema::ResultSet::Video;
+
+use DBIx::Class::Helper::ResultSet::Random;
+
+use base 'DBIx::Class::ResultSet';
+
+__PACKAGE__->load_components( 'Helper::ResultSet::Random' );
+
+1;
@@ -0,0 +1,18 @@
+--
+-- Created by SQL::Translator::Producer::MySQL
+-- Created on Sun Aug 12 18:40:00 2012
+--
+;
+SET foreign_key_checks=0;
+--
+-- Table: `dbix_class_deploymenthandler_versions`
+--
+CREATE TABLE `dbix_class_deploymenthandler_versions` (
+ `id` integer NOT NULL auto_increment,
+ `version` varchar(50) NOT NULL,
+ `ddl` text,
+ `upgrade_sql` text,
+ PRIMARY KEY (`id`),
+ UNIQUE `dbix_class_deploymenthandler_versions_version` (`version`)
+);
+SET foreign_key_checks=1
@@ -0,0 +1,16 @@
+--
+-- Created by SQL::Translator::Producer::MySQL
+-- Created on Sun Aug 12 18:40:00 2012
+--
+;
+SET foreign_key_checks=0;
+--
+-- Table: `video`
+--
+CREATE TABLE `video` (
+ `video_id` integer NOT NULL auto_increment,
+ `yt_id` text NOT NULL,
+ PRIMARY KEY (`video_id`),
+ UNIQUE `video_yt_id` (`yt_id`)
+);
+SET foreign_key_checks=1
@@ -0,0 +1,17 @@
+--
+-- Created by SQL::Translator::Producer::PostgreSQL
+-- Created on Sun Aug 12 18:40:00 2012
+--
+;
+--
+-- Table: dbix_class_deploymenthandler_versions
+--
+CREATE TABLE "dbix_class_deploymenthandler_versions" (
+ "id" serial NOT NULL,
+ "version" character varying(50) NOT NULL,
+ "ddl" text,
+ "upgrade_sql" text,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "dbix_class_deploymenthandler_versions_version" UNIQUE ("version")
+);
+
@@ -0,0 +1,15 @@
+--
+-- Created by SQL::Translator::Producer::PostgreSQL
+-- Created on Sun Aug 12 18:39:59 2012
+--
+;
+--
+-- Table: video
+--
+CREATE TABLE "video" (
+ "video_id" serial NOT NULL,
+ "yt_id" text NOT NULL,
+ PRIMARY KEY ("video_id"),
+ CONSTRAINT "video_yt_id" UNIQUE ("yt_id")
+);
+
@@ -0,0 +1,18 @@
+--
+-- Created by SQL::Translator::Producer::SQLite
+-- Created on Sun Aug 12 18:40:00 2012
+--
+
+;
+BEGIN TRANSACTION;
+--
+-- Table: dbix_class_deploymenthandler_versions
+--
+CREATE TABLE dbix_class_deploymenthandler_versions (
+ id INTEGER PRIMARY KEY NOT NULL,
+ version varchar(50) NOT NULL,
+ ddl text,
+ upgrade_sql text
+);
+CREATE UNIQUE INDEX dbix_class_deploymenthandler_versions_version ON dbix_class_deploymenthandler_versions (version);
+COMMIT
@@ -0,0 +1,16 @@
+--
+-- Created by SQL::Translator::Producer::SQLite
+-- Created on Sun Aug 12 18:40:00 2012
+--
+
+;
+BEGIN TRANSACTION;
+--
+-- Table: video
+--
+CREATE TABLE video (
+ video_id INTEGER PRIMARY KEY NOT NULL,
+ yt_id text NOT NULL
+);
+CREATE UNIQUE INDEX video_yt_id ON video (yt_id);
+COMMIT
@@ -0,0 +1,174 @@
+---
+schema:
+ procedures: {}
+ tables:
+ dbix_class_deploymenthandler_versions:
+ constraints:
+ - deferrable: 1
+ expression: ''
+ fields:
+ - id
+ match_type: ''
+ name: ''
+ on_delete: ''
+ on_update: ''
+ options: []
+ reference_fields: []
+ reference_table: ''
+ type: PRIMARY KEY
+ - deferrable: 1
+ expression: ''
+ fields:
+ - version
+ match_type: ''
+ name: dbix_class_deploymenthandler_versions_version
+ on_delete: ''
+ on_update: ''
+ options: []
+ reference_fields: []
+ reference_table: ''
+ type: UNIQUE
+ fields:
+ ddl:
+ data_type: text
+ default_value: ~
+ is_nullable: 1
+ is_primary_key: 0
+ is_unique: 0
+ name: ddl
+ order: 3
+ size:
+ - 0
+ id:
+ data_type: int
+ default_value: ~
+ is_auto_increment: 1
+ is_nullable: 0
+ is_primary_key: 1
+ is_unique: 0
+ name: id
+ order: 1
+ size:
+ - 0
+ upgrade_sql:
+ data_type: text
+ default_value: ~
+ is_nullable: 1
+ is_primary_key: 0
+ is_unique: 0
+ name: upgrade_sql
+ order: 4
+ size:
+ - 0
+ version:
+ data_type: varchar
+ default_value: ~
+ is_nullable: 0
+ is_primary_key: 0
+ is_unique: 1
+ name: version
+ order: 2
+ size:
+ - 50
+ indices: []
+ name: dbix_class_deploymenthandler_versions
+ options: []
+ order: 1
+ triggers: {}
+ views: {}
+translator:
+ add_drop_table: 0
+ filename: ~
+ no_comments: 0
+ parser_args:
+ package: &1 !!perl/hash:Web::Scenefinity::Schema
+ class_mappings:
+ DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult: __VERSION
+ Web::Scenefinity::Schema::Result::Video: Video
+ source_registrations:
+ Video: !!perl/hash:DBIx::Class::ResultSource::Table
+ _columns:
+ video_id:
+ data_type: integer
+ is_auto_increment: 1
+ yt_id:
+ data_type: text
+ _columns_info_loaded: 0
+ _ordered_columns:
+ - video_id
+ - yt_id
+ _primaries: &2
+ - video_id
+ _relationships: {}
+ _unique_constraints:
+ primary: *2
+ video_yt_id:
+ - yt_id
+ name: video
+ result_class: Web::Scenefinity::Schema::Result::Video
+ resultset_attributes: {}
+ resultset_class: Web::Scenefinity::Schema::ResultSet::Video
+ schema: *1
+ source_name: Video
+ __VERSION: !!perl/hash:DBIx::Class::ResultSource::Table
+ _columns:
+ ddl:
+ data_type: text
+ is_nullable: 1
+ id:
+ data_type: int
+ is_auto_increment: 1
+ upgrade_sql:
+ data_type: text
+ is_nullable: 1
+ version:
+ data_type: varchar
+ size: 50
+ _columns_info_loaded: 0
+ _ordered_columns:
+ - id
+ - version
+ - ddl
+ - upgrade_sql
+ _primaries: &3
+ - id
+ _relationships: {}
+ _unique_constraints:
+ dbix_class_deploymenthandler_versions_version:
+ - version
+ primary: *3
+ name: dbix_class_deploymenthandler_versions
+ result_class: DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult
+ resultset_attributes: {}
+ resultset_class: DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResultSet
+ schema: *1
+ source_name: __VERSION
+ storage: !!perl/hash:DBIx::Class::Storage::DBI
+ _connect_info:
+ - ~
+ _dbh_details: {}
+ _dbh_gen: 0
+ _dbi_connect_info:
+ - ~
+ - ~
+ - ~
+ - &4
+ AutoCommit: 1
+ PrintError: 0
+ RaiseError: 1
+ ShowErrorStatement: 1
+ _dbic_connect_attributes: *4
+ _in_do_block: 0
+ _sql_maker: ~
+ _sql_maker_opts: {}
+ savepoints: []
+ schema: *1
+ transaction_depth: 0
+ sources:
+ - __VERSION
+ parser_type: SQL::Translator::Parser::DBIx::Class
+ producer_args: {}
+ producer_type: SQL::Translator::Producer::YAML
+ show_warnings: 0
+ trace: 0
+ version: 0.11011
Oops, something went wrong.

0 comments on commit 59dc86d

Please sign in to comment.