forked from JohnMcLear/Transfer-Video-from-Youtube-to-Vimeo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
105 changed files
with
35,900 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
config.php | ||
config.ini | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
define('STORE_FILE', '/tmp/vimeo-upload-store.php'); | ||
|
||
$filename = $argv[1]; | ||
$hash = md5_file($filename); | ||
|
||
if (file_exists(STORE_FILE)){ | ||
$store = require STORE_FILE; | ||
} else { | ||
$store = array(); | ||
} | ||
|
||
$store[$hash] = $filename; | ||
|
||
$codeString = var_export($store, true); | ||
|
||
$code = '<?php return '.$codeString.';'; | ||
|
||
file_put_contents(STORE_FILE, $code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
define('STORE_FILE', '/tmp/vimeo-upload-store.php'); | ||
|
||
$filename = $argv[1]; | ||
$hash = md5_file($filename); | ||
|
||
if (file_exists(STORE_FILE)){ | ||
$store = require STORE_FILE; | ||
} else { | ||
// If there's no store the file hasn't been uploaded | ||
exit(0); | ||
} | ||
|
||
if (isset($store[$hash])){ | ||
// The file has already been uploaded | ||
exit(1); | ||
} | ||
|
||
// If we've got to here then the file hasn't been uploaded before | ||
exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
error_reporting(-1); | ||
|
||
define('CONFIG_FILE', __DIR__.'/../config.ini'); | ||
|
||
function stdout($data){ | ||
fputs(STDOUT, $data, strlen($data)); | ||
} | ||
|
||
function stderr($data){ | ||
fputs(STDERR, $data, strlen($data)); | ||
} | ||
|
||
spl_autoload_register(function($class){ | ||
$class = str_replace('\\', '/', $class); | ||
require __DIR__."/../Library/{$class}.php"; | ||
}); | ||
|
||
set_exception_handler(function($e){ | ||
$type = get_class($e); | ||
stderr("Uncaught {$type} [{$e->getCode()}]: {$e->getMessage()}\n"); | ||
stderr($e->getTraceAsString().PHP_EOL); | ||
exit(1); | ||
}); | ||
|
||
if (!file_exists(CONFIG_FILE)){ | ||
stderr("You must create a config.ini file in ".realpath(__DIR__.'/../')); | ||
exit(1); | ||
} | ||
|
||
$settings = parse_ini_file(CONFIG_FILE, true); | ||
|
||
if (!$settings){ | ||
stderr("Failed to parse [".CONFIG_FILE."] as valid ini file"); | ||
} | ||
|
||
return (object) $settings; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
return (object) array( | ||
'help' => array( | ||
'general' => | ||
"Usage: tvyv <command> [<args>]\n". | ||
"\n". | ||
"Commands:\n". | ||
" upload\n". | ||
"\n". | ||
"See 'tvyv help <command>' for more information on a specifc command", | ||
|
||
'upload' => | ||
"Usage 1: tvyv upload <dir>\n". | ||
"Usage 2: tvyv upload <file>\n" | ||
) | ||
); | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
abstract class Factory { | ||
protected $settings; | ||
|
||
public function __construct($settings){ | ||
$this->settings = $settings; | ||
} | ||
|
||
abstract public function make(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
namespace Factory; | ||
|
||
class Logger extends \Factory { | ||
|
||
public function make(){ | ||
switch ($this->settings->log['type']){ | ||
case 'file': | ||
// Make relative files relative to the config file | ||
$file = $this->settings->log['file']; | ||
if (!is_writable($file)){ | ||
throw new \InvalidArgumentException("[{$file}] is not writable"); | ||
} | ||
if (in_array(substr($file, 0, 2), array('./', '..'))){ | ||
$file = __DIR__.'/../../'.$file; | ||
} | ||
return new \Logger\File($this->settings->log['level'], $file); | ||
break; | ||
|
||
case 'screen': | ||
return new \Logger\Screen($this->settings->log['level']); | ||
break; | ||
|
||
case 'null': | ||
default: | ||
return new \Logger\Null($this->settings->log['level']); | ||
break; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Factory directory | ||
Factories for creating other objects. | ||
|
||
Filenames and classnames should map to abstract classes in the level above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
namespace Factory; | ||
|
||
class Vimeo extends \Factory { | ||
protected $settings; | ||
|
||
public function __construct(\StdClass $settings){ | ||
$this->settings = $settings; | ||
} | ||
|
||
public function make(){ | ||
if ($this->haveToken()){ | ||
$client = new \Vimeo\Client( | ||
$this->settings->vimeo['consumer_key'], | ||
$this->settings->vimeo['consumer_secret'], | ||
$this->settings->vimeo['token'], | ||
$this->settings->vimeo['token_secret'] | ||
); | ||
} else { | ||
$client = new \Vimeo\Client( | ||
$this->settings->vimeo['consumer_key'], | ||
$this->settings->vimeo['consumer_secret'] | ||
); | ||
} | ||
|
||
return $client; | ||
} | ||
|
||
public function haveToken(){ | ||
if (!isset($this->settings->vimeo['token'])) return false; | ||
if (!$this->settings->vimeo['token']) return false; | ||
if (!isset($this->settings->vimeo['token_secret'])) return false; | ||
if (!$this->settings->vimeo['token_secret']) return false; | ||
return true; | ||
} | ||
} | ||
|
Oops, something went wrong.