Jump to content


These Forums Are Now Read-Only


For TubePress support, please post a question here or open a support ticket and we will be glad to assist.


Photo

Get video ID


  • Please log in to reply
9 replies to this topic

#1 e. p.

e. p.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 21 May 2012 - 04:23 AM

hi everybody

i need to obtain the ID for the last posted video in a Vimeo Album

is there a way to obtain this information via the TubePress functions?

thanks in advance

#2 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 23 May 2012 - 06:55 PM

Hi,

Unfortunately this isn't (yet) supported. If you're familiar with PHP, you could certainly dig around in the code to see if you could hack something together. In the future I plan on adding first-class support for this type of low-level programming, but we're just not there yet.

Could you describe a bit more what you're looking to do? Hopefully there's a way to get TubePress to achieve your goal without having to do anything special.

#3 e. p.

e. p.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 23 May 2012 - 10:11 PM

hi Eric,

i'm working at this site:

http://kappapiu.com/...deo-production/

when one of the "service" page loads i check if there's a video ID in the URL, if there's none i would like to reload the page with the first video in the corresponding vimeo album

in order to obtain this i need to get the ID of the first video

that's it

thank you, cheers

#4 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 25 May 2012 - 09:01 PM

You could grab the first video's ID in JavaScript with the following jQuery code:

jQuery("div.tubepress_thumbnail_area div.pap-tpress-thmb-container:first a").attr("href").split("=")[1]
So you could have some code like the following to achieve what you're after:

if (location.search.indexOf("tubepress_video") === -1) {

    var firstVideoId = jQuery("div.tubepress_thumbnail_area div.pap-tpress-thmb-container:first a").attr("href").split("=")[1];

    //reload page with firstVideoId
}
Do you think that would work for you?

#5 e. p.

e. p.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 28 May 2012 - 02:55 AM

if (location.search.indexOf("tubepress_video") === -1) {

    var firstVideoId = jQuery("div.tubepress_thumbnail_area div.pap-tpress-thmb-container:first a").attr("href").split("=")[1];

    //reload page with firstVideoId
}

hi Eric, your code returns an error on my page:

Parse error: syntax error, unexpected T_VAR in /accounts/kappapiu/www/kappapiu.com/2012/wp-content/themes/1140FluidStarkers_child/kplus-services.php on line 61

and (if i understand well) it requires the whole page to be created in order to work, i was hoping to resolve this issue at the very beginning of the page, do you tink i should directly use Vimeo APIs to obtain the ID ?

i'm scared it would be quite a slow solution, becuse of the amont of data retrieved for the album and also because i have no idea of how to cache the results (i'm a designer not a programmer)

a piece of advice from you would be very appreciated...

cheers

#6 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 29 May 2012 - 10:50 PM

hi Eric, your code returns an error on my page:

Parse error: syntax error, unexpected T_VAR in /accounts/kappapiu/www/kappapiu.com/2012/wp-content/themes/1140FluidStarkers_child/kplus-services.php on line 61


That error appears to be coming from your theme, actually, in the file wp-content/themes/1140FluidStarkers_child/kplus-services.php.

and (if i understand well) it requires the whole page to be created in order to work, i was hoping to resolve this issue at the very beginning of the page, do you tink i should directly use Vimeo APIs to obtain the ID ?


That's correct - this particular method is JavaScript-based and thus would require the whole page to load first. If you'd like to fetch the video ID using PHP, and add caching on top of it, I'm afraid that it would require some non-trivial PHP code. In a few months I'd like to add that kind of low-level API, but it's simply not there right now.

#7 e. p.

e. p.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 30 May 2012 - 07:49 AM

hi Eric, your code returns an error on my page:

Parse error: syntax error, unexpected T_VAR in /accounts/kappapiu/www/kappapiu.com/2012/wp-content/themes/1140FluidStarkers_child/kplus-services.php on line 61


That error appears to be coming from your theme, actually, in the file wp-content/themes/1140FluidStarkers_child/kplus-services.php.



ies, because that's the place where i put your code, wrong place?

#8 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 30 May 2012 - 05:47 PM

The code I posted was JavaScript, so it'll need to be placed somewhere that can be executed by the web browser. You can leave it in a PHP file if you want, just make sure that it's outside the "
<?php  $x = $y + 1;  //some more PHP  ...?>if (location.search.indexOf("tubepress_video") === -1) {   ...}<?php  //more php here...


#9 e. p.

e. p.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 31 May 2012 - 04:58 AM

ok Eric,

i finally managed to use your solution in my page, it's a bit slow, but it works, and for the moment it's ok

thank you very much!

#10 e. p.

e. p.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 01 June 2012 - 09:46 AM

hi Eric

i've found an annoying side effect using this method: the link in the pagination carry on the video ID, influencing the video list in the next pages, you can see the problem here:

http://kappapiu.com/..._video=43017739

the pagination link are like this:

http://kappapiu.com/...ubepress_page=2

this compromises the video list and consequentially the video playing

any idea of how to fix the issue?

thanks in advance