0

I've a route which says like /video/:_id/:slug

now on this route I want to get the video url from the _id and now I want to scrap that url and I want to send this url as a source to video element in html

I tried like below but it is not working

this.route("video",{
      path:'/video/:_id/:slug',
       waitOn: function() {
         Meteor.subscribe('singleVideo', this.params._id);

      },
      onBeforeAction: function () {

      },
      data:function(){
            Session.set("currentVideoId",this.params._id);
            var video;
            video= Videos.findOne({_id: this.params._id});
            Meteor.call("videoData",video.videourl,function(er,da){
              Session.set('vurl',da);
          });
            console.log(video);
            return {
              video:video
            };
      },

in the html

<video id="videoId" class="video-js vjs-default-skin vjs-big-play-centered"   
              controls  width="720" height="480"
              poster="{{video.thumbs}}">
             <source  type='video/mp4' src="{{uurl}}" />
             <!-- <source  type='video/mp4'  /> -->
        </video>

In the JS

 'uurl':function(){
        urlDep.depend();
        console.log("changed");
        return Session.get("vurl");
    }

I know this is a bad practice, Is there any standard way of doing this,because this is not working my server method

 page.open(url, function (status) {
                page.getContent(function(content) {

                    var $ = cheerio.load(content);
                    var mp4Link = $('#xvideos_pic > a').attr('href');
                    console.log(mp4Link);
                     fut.return(mp4Link);
                });
            });
             return fut.wait();

Any suggestions on how to do it?

user1934044
  • 516
  • 5
  • 18
  • If you do session.get vurl in the console do you get anything? – Eliezer Steinbock Oct 02 '14 at 07:50
  • yeah,first I'm getting eror then got the vurl – user1934044 Oct 02 '14 at 08:57
  • Well you get the error because you don't have a url for the video when the page loads. After that you get the url but it doesn't reload the video. You need to get it to load only after getting the url. Maybe only adding the video html to the page once you have the url will solve the problem. Show loading while waiting or something – Eliezer Steinbock Oct 03 '14 at 09:45
  • thx for the reply, Yeah already did that, as scrapper takes some time, the spinner is showing more time than usual – user1934044 Oct 03 '14 at 12:22

0 Answers0