0

Let me say here at the start I am not a programmer, just interested..

I am trying to load a file to youtube on the first day of the month and set the file name as the lastmonth-thisyear.avi like March-2012.avi

I have tried this but get an error:

File to be uploaded at /Jpeg2/movies/"$THISMONTH"-"$THISYEAR".avi does not exist or is not readable.Done!

It does not read in the variables.

$THISDAY=date("d");
$THISMONTH=date("F");
$THISYEAR=date("Y");
$LASTMONTH = mktime(0, 0, 0, date("m")-1, date("d"),   date("Y"));
$LASTYEAR = mktime(0, 0, 0, date("m"),   date("d"),   date("Y")-1);

// this I hope makes the file December-2012
if ($THISDAY="01") {
	$THISMONTH=$LASTMONTH;
	$THISYEAR=$LASTYEAR;
  }


$filesource = $yt->newMediaFileSource('/var/www/localhost/htdocs/Jpeg2/movies/"$THISMONTH"-"$THISYEAR").avi');

$filesource->setContentType('video/avi');

// set slug header

$filesource->setSlug('"$THISMONTH"-"$THISYEAR".avi');

Cheers

3
Contributors
10
Replies
11
Views
5 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1
    diafol 3,720   5 Years Ago

    [QUOTE=Dingo001;1773868]This thread can be closed. Thanks for your help, but found another way.[/QUOTE] You're the only one that can mark this solved (link below). If you have found another way, please post your solution here as it may help others. Read More

0
$filesource = $yt->newMediaFileSource("/var/www/localhost/htdocs/Jpeg2/movies/$THISMONTH-$THISYEAR.avi");

$filesource->setSlug("$THISMONTH-$THISYEAR.avi");

Edited by pritaeas: n/a

0

Thanks I think that will work but found out my values were wrong for my variables and the if statement is not working.

for this bit of code:

$THISDAY=date("d");
$THISMONTH=date("F");
$THISYEAR=date("Y");
$LASTMONTH = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); 
$LASTYEAR = mktime(0, 0, 0, date("m"),   date("d"),   date("Y")-1);
echo "This day = $THISDAY \n";
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";
echo "Last Month = $LASTMONTH  \n";
echo "Last Year = $LASTYEAR  \n";

if ($THISDAY="01") {
	$THISMONTH=$LASTMONTH;
	$THISYEAR=$LASTYEAR;
  }
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";

$filesource = $yt->newMediaFileSource("/var/www/localhost/htdocs/Jpeg2/movies/$THISMONTH-$THISYEAR.avi");

$filesource->setContentType('video/avi');

// set slug header

$filesource->setSlug("$THISMONTH-$THISYEAR.avi");

I got this which indicates the if statement is not working.

Authenticating client...
Uploading video...
This day = 05
This month = March
This Year = 2012
Last Month = 1328360400
Last Year = 1299243600
This month = 1328360400
This Year = 1299243600
File to be uploaded at /var/www/localhost/htdocs/Jpeg2/movies/1328360400-1299243600.avi does not exist or is not readable.Done!

I also want $LASTMONTH to = February not 1328360400 and $LASTYEAR to = 2011 not 1299243600.

Your help is appreciated.
Giles

0

So let me get this right, if you upload on 1st of March 2012, you want the name to be FEBRUARY-2012.avi and if it is say, 1st of January 2013, you want it to say DECEMBER-2011.avi?

OK:

$year = date('Y');
$monthname= date('F');
if(date('n') == 1){
  $year = $year - 1;
  $monthname = "DECEMBER";
}
$filename = $monthname . '-' . $year . '.avi';

Do you upload on any other days (other than the 1st of the month)? If so, this code won't do - but I'm a bit confused as it sounds as though you only upload on the 1st in your post, but then in your code you have something to do with the 1st day.

0

OK getting a bit closer except the filename is still comming out as this month not last month and also has the . in it.

This is what I have now:

$THISMONTH=date("F");
$THISYEAR=date("Y");
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";
if (date('n') == 1){
	$THISYEAR = $THISYEAR - 1;
	// $THISMONTH = "December";
		
  }
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";

$filesource = $yt->newMediaFileSource("/var/www/localhost/htdocs/Jpeg2/movies/$THISMONTH . '-' . $THISYEAR . '.avi'");

$filesource->setContentType('video/avi');

// set slug header

$filesource->setSlug("$THISMONTH - 1 . '-' . $THISYEAR . '.avi'");

I added the last line because I will have the same problem as the line above it.


When I run this I get this error:

Authenticating client...
Uploading video...
This month = March
This Year = 2012
This month = March
This Year = 2012
File to be uploaded at /var/www/localhost/htdocs/Jpeg2/movies/March . '-' . 2012 . '.avi' does not exist or is not readable.Done!


When I run this today it should be /var/www/localhost/htdocs/Jpeg2/movies/February-2012.avi'

I originally needed today because it was used in the if statement before it was changed.

I upload a video every day to youtube and at the end of the month I combine them all into one timelapse video. So the video for February will be uploaded in March but the name of the file needs to be February.

Edited by Dingo001: n/a

0
$year = date('Y');
$monthname= date('F');
if(date('n') == 1){
  $year = $year - 1;
  $monthname = "DECEMBER";
}
$filename = strtoupper($monthname) . '-' . $year . '.avi';

The code doesn't work?

0

Yes that did not work as running your code I still got MARCH.

I managed to find out what last month was but the file name line is still in error:


Line 44 --> $filesource = $yt->newMediaFileSource('/var/www/localhost/htdocs/Jpeg2/movies/'$LASTMONTH . '-' . $THISYEAR . '.avi');

I think I will have the same problem with these lines as well

$filesource->setSlug($THISMONTH-$THISYEAR.avi);

$myVideoEntry->setVideoTitle('Monthly videos from Albury N.S.W. Australia for $THISMONTH-$THISYEAR');

The code I have

$THISMONTH=date("F");
$THISYEAR=date("Y");
$LASTMONTH=date("F",strtotime(-date('j') . ' days'));
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";
echo "Last Month = $LASTMONTH  \n";
if (date('n') == 1){
	$THISYEAR = $THISYEAR - 1;
	$THISMONTH = "December";
		
  }
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";

$filesource = $yt->newMediaFileSource('/var/www/localhost/htdocs/Jpeg2/movies/'$LASTMONTH . '-' . $THISYEAR . '.avi');

$filesource->setContentType('video/avi');

// set slug header

$filesource->setSlug($THISMONTH-$THISYEAR.avi);



// add the filesource to the video entry

$myVideoEntry->setMediaSource($filesource);



$myVideoEntry->setVideoTitle('Monthly videos from Albury N.S.W. Australia for $THISMONTH-$THISYEAR');

This is the error I get

PHP Parse error: syntax error, unexpected T_VARIABLE in /var/www/localhost/htdocs/scripts/youtube-upload-monthly.php on line 44

0

I got the code to work the video is uploading now.

$THISMONTH=date("F");
$THISYEAR=date("Y");
$LASTMONTH=date("F",strtotime(-date('j') . ' days'));
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";
echo "Last Month = $LASTMONTH  \n";
if (date('n') == 1){
	$THISYEAR = $THISYEAR - 1;
	$THISMONTH = "December";
		
  }
echo "This month = $THISMONTH  \n";
echo "This Year = $THISYEAR \n";

$filesource = $yt->newMediaFileSource("/var/www/localhost/htdocs/Jpeg2/movies/$LASTMONTH/$LASTMONTH-$THISYEAR.avi");

$filesource->setContentType('video/avi');

// set slug header

$filesource->setSlug("$THISMONTH-$THISYEAR.avi");



// add the filesource to the video entry

$myVideoEntry->setMediaSource($filesource);





$myVideoEntry->setVideoTitle("Monthly videos from Albury N.S.W. Australia for $THISMONTH-$THISYEAR");
0

sorry forgot the last month bit. DOh!

$filename= strtoupper(date('F-Y',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")))) . ".avi";

Edited by diafol: n/a

0

This thread can be closed. Thanks for your help, but found another way.

1

This thread can be closed. Thanks for your help, but found another way.

You're the only one that can mark this solved (link below).

If you have found another way, please post your solution here as it may help others.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.