[ Video Sharing CMS v4 ] News fields in Database videos table

Started by ggmustafa85,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ggmustafa85Topic starter

Hello,
I added some extra fields in videos tablet, like channelerror, country, etc. and i edited the insert query "moderator/add-video.php" page. But whenever I import a new youtube video, these new fields are not updated. News insert queries are;

$db->query("INSERT INTO ".DB_PREFIX."videos (`privacy`,`pub`,`source`, `user_id`, `date`, `thumb`, `title`, `duration`, `tags` ,  `liked` , `category`, `description`, `nsfw`, `views`, `featured`, `channelerror`, `epg`, `country`, `situation`) VALUES 
('".intval(_post('priv'))."','".intval(_post('pub'))."','"._post('file')."', '"._post('owner')."', now() , '".$thumb."', '".toDb(_post('title')) ."', '".$sec."', '".toDb(_post('tags'))."', '0','".toDb(_post('categ'))."','".toDb(_post('description'))."','".toDb(_post('nsfw'))."','".intval(_post('views'))."','".intval(_post('featured'))."', '0', '', 'afghanistan', '1')");   
} else {
//if it's remote file
$db->query("INSERT INTO ".DB_PREFIX."videos (`privacy`,`pub`,`remote`, `user_id`, `date`, `thumb`, `title`, `duration`, `tags`, `liked` , `category`, `description`, `nsfw`, `views`, `featured`, `channelerror`, `epg`, `country`, `situation`) VALUES 
('".intval(_post('priv'))."','".intval(_post('pub'))."','"._post('file')."', '"._post('owner')."', now() , '".$thumb."', '".toDb(_post('title')) ."', '".$sec."', '".toDb(_post('tags'))."', '0','".toDb(_post('categ'))."','".toDb(_post('description'))."','".toDb(_post('nsfw'))."','".intval(_post('views'))."','".intval(_post('featured'))."', '0', '', 'afghanistan', '1')");


Can you tell me, what to change in the code to get these values in the table?
  •  

Marius P.

Hi, welcome to the support boards!

Do you try to add the youtube videos using the add video? Or using the Youtube importer?

Cause for the importer the part to edit is in lib/class.youtube.php

function youtube_import($video=array(), $cat = null, $owner = null) {
global $db;
if(is_null($owner)) {$owner = get_option('importuser','1');}
if(isset($video["videoid"]) && isset($video["title"]) ) {
$video["path"] = 'http://www.youtube.com/watch?v='.$video["videoid"];
$db->query("INSERT INTO ".DB_PREFIX."videos (`pub`,`source`, `user_id`, `date`, `thumb`, `title`, `duration`, `tags` , `views` , `liked` , `category`, `description`, `nsfw`) VALUES 
('".intval(get_option('videos-initial'))."','".$video["path"]."', '".$owner."', now() , '".$video["thumbnail"]."', '".toDb($video["title"]) ."', '".intval($video["duration"])."', '".toDb(_post('tags'))."', '0', '0','".toDb($cat)."','".toDb($video["description"])."','0')");   
//var_dump($video);
} else {
echo '<p><span class="redText">Missing video id or title </span></p>';
}
}
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

Let me know more details so I can help out.
Basically for add video page you did everything good in the
//if it's web link
web query.
But that's for the admin page /moderator/?sk=add-video
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

Thank you, that worked like a charm. I was trying it for the youtube videos.
I have one other problem. I want to insert the selected youtube videos in the list from bottom to top to db table. I couldn't figure out how to do it. Plus is it possible to display the youtube video from endpage in 1st page and vice versa?
Should I open a new topic for this or you can give support here?
  •  

Marius P.

Quote from: ggmustafa85 on
Thank you, that worked like a charm. I was trying it for the youtube videos.
I have one other problem. I want to insert the selected youtube videos in the list from bottom to top to db table. I couldn't figure out how to do it. Plus is it possible to display the youtube video from endpage in 1st page and vice versa?
Should I open a new topic for this or you can give support here?

Hi, check this please http://www.phpvibe.com/forum/how-to/a-way-to-import-youtube-videos-so-newest-first/
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

Actually I have already read this, and I'm trying to do something what Hersh has done in the last post. And I know getting last page is not easy task, but at least we can use this trick mentioned by Hersh. But i don't know how to insert the manually selected videos in reversed order. For now for example, if I select 3 video, the 1st video will be added 1st and the 3rd lastly. But i want that the 3rd video is added 1st, then 2nd and then 3rd. There is must be some loop behind it, which i can't find.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

Try to reverse the array https://php.net/manual/ro/function.array-reverse.php here (youtube1-by-1.php)

foreach ($_POST['checkRow'] as $raw) {
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

Didn't get you totally, I tried to reserve importer, but didn't work.
What to change here
<?php $importer = array_merge($_GET, $_POST);
$importer['auto'] = false;
$importer['allowduplicates'] = false;
if(isset($_POST['checkRow'])) {
foreach ($_POST['checkRow'] as $raw) {
$video = base64_decode($raw);
youtube_import(maybe_unserialize($video), intval($_POST['categ']),$importer['owner']);
}
echo '<div class="msg-info">Selected videos have been imported.</div>';
}
  •  

Marius P.

I didn't get you much neither. I thought you refer to the 1 by 1 with the select 1-2-3 videos.

If you really refer to that than your video are in this array when posting:

$_POST['checkRow']



and an array can be reversed.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

Thank you that worked.
So now about getting inserting videos from last page. As Hersh has written in http://www.phpvibe.com/forum/how-to/a-way-to-import-youtube-videos-so-newest-first/ , "I use the the end page for "auto push" (e.g. page 20) as the starting point and import videos backwards from the last page to first.". Is this possible and how?
  •  

Marius P.

Quote from: ggmustafa85 on
Thank you that worked.
So now about getting inserting videos from last page. As Hersh has written in http://www.phpvibe.com/forum/how-to/a-way-to-import-youtube-videos-so-newest-first/ , "I use the the end page for "auto push" (e.g. page 20) as the starting point and import videos backwards from the last page to first.". Is this possible and how?

I assume he tweaked/changed this_page(), for example:

change this_page() to fakep();

and do this

function fakep() {
$new = 25 - this_page();
return $new;
}



But this is purely theoretical, haven't tried it.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

What is does is calculate current page based on 25 (you can change this value) minus the actual current page.
So first page will be 24, then decrease...
This would be the minimalist coding solution for me.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

But where is this_page() function defined? Or i can create fakep() function in youtube 1by1 page and use it instead  this_page()?
  •  

Marius P.

Quote from: ggmustafa85 on
But where is this_page() function defined? Or i can create fakep() function in youtube 1by1 page and use it instead  this_page()?

Use instead, this_page is very global and used everywhere (frontend and backend).
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

and how do i decrease the result? any function used for it?
  •  

Marius P.

The pagination should decrease automatically with this hack.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

No, its not decreasing automatically. Says no more videos or something. Fakep() function is working fine, as I printed the result and its giving the last page. somehow there is something else to change too.
  •  

Marius P.

It is probably starting from a to big page.
Every result has a limit, which can be as high to 24 pages, or just 2-03 pages, depending on what their API returns.
If there is no result, it start from a to high page, try switching to next page until your see results.
This is, as explained in that thread, the big downfall for reversing.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

But there is no next on the page, just shows blank page with message "No (more) videos found"
  •  

Marius P.

Quote from: ggmustafa85 on
But there is no next on the page, just shows blank page with message "No (more) videos found"

Uh, didn't saw that coming.

Try to copy:

$a = new pagination;   
$a->set_current(this_page());
$a->set_first_page(true);
$a->set_pages_items(12);
$a->set_per_page($nb_display);
$a->set_values(500);$a->show_pages($pagi_url);



just before this lines





//end if data
//end actions
//render forms
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

You may also need to increase a bit that 500 on values

$a->set_values(500);
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

Seems like for youtube 1by1 its no longer needed to display the last page, because i can simply click and select the last page. But I'm trying to this solution for automatic youtube. 1st of all there is no array which I can reverse like i did for 1by1, secondly i created this fakep function, but its importing like normal from 1st to last page. and also pasted the code you mentioned.
  •  

Marius P.

Did you changed all instances in there for this_page() to fakep() (make sure you don't change it in the fakep definition also)?
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ggmustafa85Topic starter

yea, there was 1 more instance of this_page remaining, but now it has strange behavior. import page 24 and stops and when i click some other page, then it selects some random page and import the videos. Can you check the website yourself? I can send you cpanel and admin panel login details.
  •  

Similar topics (7)