Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Help with regex?
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2023-01-16 14:03:50
I spent a few days working this out, and here is what I have. It works, although it may be that there is a bit of redundancy in it since I started getting a headache trying different things lol. The main issue here is it will grab any URL in the string, and I cant do regex, so it would be best if it only grabbed links containing IMDB or variants. This code will check your DESCR and grab the link from it and put it in the DB under imdb when using that table, such as the OMDB mod
//Get any IMDB link from descr and load it into the DB under imdb
$timdb = SQL_Query_exec("SELECT descr FROM torrents WHERE id = $id");
$bang = mysqli_fetch_assoc($timdb);
$bang2 = implode(" ",$bang);
preg_match_all('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', $bang2, $matches);
$urls = $matches[0];

function array_map_callback($url)
{
 return mysqli_real_escape_string($GLOBALS["DBconnector"], $url);
}
array_map('array_map_callback', $urls);
foreach ($urls as $url) {
   SQL_Query_exec("UPDATE `torrents` SET `imdb`= '".$url."' WHERE id = $id");
}

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2023-01-16 16:35:45
I think I got it, but if anyone see something silly in that code, please tell. I ran in circles a few times for that. and regex is just a foreign language
preg_match_all('/\b(https?):\/\/(www).(imdb.com)[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', $bang2, $matches);

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2023-01-16 20:24:39
imdb.com\/title\/(.*)\/


imdb.com\/title\/tt([0-9]*)



sort this :

array(2
0=>array(1
  0=>imdb.com/title/tt0083944/)
1=>array(1
  0=>tt0083944
)
)


Ubuntu Linux 20.04.3 | MySQL 8 | Apache 2.4.41 | PHP 8.1.1

Last edited by kiki2020 on 2023-01-16 20:36:51
2023-01-16 22:06:40

$string = 'http://www.imdb.com/title/tt2488496/?ref_=nv_sr_1
http://www.imdb.com/title/tt2488496/
https://www.imdb.com/title/tt2488496
imdb.com/title/tt2488496
tt2488496
imdb.com/title/season2488496
http://www.imdb.com/title/tt2488496
http://www.imdb.com/news/ni59315274
www.imdb.com/title/tt2488496/?ref_=nv_sr_1';

preg_match_all('/\/(title|news)\/(tt[0-9]+|ni[0-9]+)/', $string, $matches);
print_r($matches[2]);


Im not sure what you want to do with the array, is this to insert the IDS (loop) and send to database?

Last edited by STorrents2020 on 2023-01-16 22:16:06
2023-01-16 23:52:31
well, sometimes an imdb link can look like this
https://www.imdb.com/title/tt8593824/?ref_=nv_sr_srsg_3

or this
https://www.imdb.com/title/tt14642626/

and I was looking for a "catch all", which the regex I managed to work out above does, but yes, this was for a insert. I dont use it, someone asked and I was curious about it, so I made that after pulling my hair out. Sometimes in the torrent description, there is an imdb link, and that was what that person asked for. I assume its for mass torrent imports with descriptions and rather than adding links to the DB for each, it will autoload on torrents-details
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2023-01-17 02:47:04
This is what is happening with that expression

https://regex101.com/r/y86LOl/1
2023-01-17 07:57:10
yea, I used that thing to build the regex I posted above. I only needed that one to grab proper imdb. That site really helped. I was pulling the entire URL in the one I needed, not just inserting the videoID. Yours works great tho for defined string, the one I was messing with is for pulling that URL from the descrition of a torrent, but usually at least http(s):// www imdb etc...... Thanks for the help tho, you guys are great :)
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2023-01-17 08:08:07
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728